【发布时间】:2012-09-28 16:54:16
【问题描述】:
我正在尝试执行一个简单的发布程序:
- (IBAction)directPostClick:(id)sender {
self.statusLabel.text = @"Waiting for authorization...";
if (self.accountStore == nil) {
self.accountStore = [[ACAccountStore alloc] init];
}
ACAccountType * facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray * permissions = @[@"publish_stream", @"user_checkins", @"publish_checkins", @"user_likes", @"user_videos"];
NSDictionary * dict = @{ACFacebookAppIdKey : @"My app id here", ACFacebookPermissionsKey : permissions, ACFacebookAudienceKey : ACFacebookAudienceOnlyMe};
[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) {
__block NSString * statusText = nil;
if (granted) {
statusText = @"Logged in";
NSArray * accounts = [self.accountStore accountsWithAccountType:facebookAccountType];
self.facebookAccount = [accounts lastObject];
NSLog(@"account is: %@", self.facebookAccount);
self.statusLabel.text = statusText;
[self postToFeed];
}
else {
self.statusLabel.text = @"Login failed";
NSLog(@"error is: %@", error);
}
}];
}
编辑: 问题是当我点击 alertView 的 OK 按钮(不允许也不起作用)时,什么也没有发生! - 这种行为现在改变了 iOS 6 Facebook posting procedure ends up with "remote_app_id does not match stored id" 所以我得到了一个错误,而不是“什么都没发生” “Facebook 服务器无法完成此访问请求:remote_app_id 与存储的 id 不匹配”
所以,似乎警报视图的点击处理程序什么都不做,我的完成处理程序永远不会被调用。 我已经有类似的问题了:iOS 6 Social integration - go to settings issue 我认为这是同样的问题。你们怎么看? 附言 我在 MAC mini、OS X 10.8.1 上运行最新的 xcode 4.5 (4G182) 并使用 iPhone 6.0 模拟器。
添加:
应 Bjorn 的请求,添加 postToFeed 方法,尽管它从未被调用:
- (void)postToFeed {
NSDictionary * parameters = @{@"message" : @"Hello world!"};
NSURL * feedUrl = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];
SLRequest * request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:feedUrl parameters:parameters];
request.account = self.facebookAccount;
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
self.statusLabel.text = @"Posted!";
});
}];
}
【问题讨论】:
-
能否请您添加您的
postToFeed方法的代码? -
是的,我会把它添加到底部的问题中
-
我不确定这是否为我解决了问题,但请确保您已在 Facebook 上正确设置了您的应用程序。将其与Facebook的集成方式设置为“Native iOS App”,填写Bundle ID(App Store ID暂时可以为0)并启用“Facebook登录”。此外,将高级选项卡中的“应用程序类型”设置为本机/桌面。您也可以将“客户端中的应用程序机密”设置为否。让我们知道这是否有助于/设置正确
-
我找不到“Native iOS app”复选框..其余设置正确
-
它在您的 Facebook 应用的“基本设置”中:“选择您的应用如何与 Facebook 集成”
标签: iphone objective-c facebook