我已经与 Facebook 集成,因此我可以将状态发布到我的提要中。我基于发布的一些代码来提供开发人员教程。从我的 iOS 应用程序运行以下 Graph API 请求时,永远不会调用请求的完成块,并且 XCode 调试日志中不会出现错误。
[FBRequestConnection
startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error) {
DLog(@"error: domain = %@, code = %d", error.domain, error.code);
} else {
DLog(@"Posted action, id: %@", result[@"id"]);
}
}];
activeSession
我有两个方便的函数在执行这个请求之前对电流进行检查。它们看起来像这样:
+ (BOOL)facebookSessionIsOpen {
return (FBSession.activeSession.isOpen);
}
+ (BOOL)facebookSessionHasPublishPermissions {
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound ||
[FBSession.activeSession.permissions indexOfObject:@"publish_stream"] == NSNotFound ||
[FBSession.activeSession.permissions indexOfObject:@"manage_friendlists"] == NSNotFound) {
return NO;
} else {
return YES;
}
}
这两个函数都返回YES
指示具有必要发布权限的活动会话。更令人困惑的是,在成功执行相同的检查后,我可以毫无问题地提取用户的个人资料(提取个人资料不需要授予发布权限),使用以下代码:
[FBRequestConnection
startWithGraphPath:@"me"
parameters:[NSDictionary dictionaryWithObject:@"picture,id,birthday,email,location,hometown" forKey:@"fields"]
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSDictionary* resultDict = (NSDictionary*)result;
NSString* emailAddress = resultDict[@"email"];
NSString* location = resultDict[@"location"][@"name"];
NSString* birthday = resultDict[@"birthday"];
NSString* homeTown = resultDict[@"hometown"][@"name"];
...
}];
有关如何调试此问题的任何建议?