您好我试图在我的iOS应用程序上发布Facebook,然后才能正常运行。现在我使用最新的SDK和以下代码。
- (无效)认证{
if (FBSession.activeSession.isOpen) {
[self promptUserWithAccountNameForUploadPhoto];
} else {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"publish_actions",
nil]; // Tried publish_stream too
[FBSession openActiveSessionWithPermissions:permissions
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// if login fails for any reason, we alert
if (error) {
// show error to user.
} else if (FB_ISSESSIONOPENWITHSTATE(status)) {
[self promptUserWithAccountNameForUploadPhoto];
}
}];
}
}
但是当它启动Facebook应用程序并完成登录时,它不会通知用户“代表您发布”,它通知我的应用程序需要您的个人资料详细信息。
当我尝试发布如下
时 -(void)promptUserWithAccountNameForUploadPhoto {
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (!error) {
NSString * msgStr = [NSString stringWithFormat:@"I have added a new Trip to %@",place];
NSString *imgStr = [NSString stringWithFormat:@"%@assets/upload/flags/%@-213x142.png",appDelegate.ServerURL,country];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Sharing Tutorial", @"name",
@"Build great social apps and get more installs.", @"caption",
@"Allow your users to share stories on Facebook from your app using the iOS SDK.", @"description",
@"https://developers.facebook.com/docs/ios/share/", @"link",
@"http://i.imgur.com/g3Qc1HN.png", @"picture",
[FBRequestConnection startWithGraphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Link posted successfully to Facebook
NSLog(@"result: %@", result);
} else {
NSLog(@"%@", error.description);
}
}];
}
}];
}
出现错误 - message =“(#200)用户尚未授权应用程序执行此操作”;