我正在创建一个ios
应用,用户只需点击一个按钮即可自动将内容共享到timeline
而不显示任何对话框。
当我使用对话框方法时,我的内容通过对话框共享。
但是当我分享没有共享对话框时,我收到此错误消息。
message = "(#200) The user hasn't authorized the application to perform this action";
我已经请求用户publish_actions
权限。
我正在使用这段代码:
NSArray *permission = [NSArray arrayWithObjects:@"public_profile", @"user_birthday",@"publish_actions",@"email", nil];
[FBSession openActiveSessionWithPublishPermissions:permission defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
if (!error){
// If the session was opened successfully
if (state == FBSessionStateOpen){
// Your code here
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"http://i.imgur.com/g3Qc1HN.png", @"picture",
nil];
// Make the request
[FBRequestConnection startWithGraphPath:@"/me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"Triffort.Com" message:@"Content Shared to Facebook" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[myAlert show];
NSLog(@"result: %@", result);
} else {
UIAlertView *myAlert = [[UIAlertView alloc]initWithTitle:@"Triffort.Com" message:@"Content Not Shared to Facebook:: Reason:: publish_actions Permission Required" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[myAlert show];
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"%@", error.description);
}
}];
}
}
}
];
我已将我的应用程序设为Live。目前我只能使用我的develpment id帐户进行分享。其他帐户显示错误。
我是否必须将此应用提交至facebook
才能执行此操作。请建议。
答案 0 :(得分:0)
问题在于您使用openActiveSessionWithReadPermissions(..)。具体来说,您正在通过" publish_actions"到readPermissions参数,它明确表示
不允许将发布权限传递给此方法。
您需要使用openActiveSessionWithPublishPermissions(..)代替
有关详细信息,请参阅https://developers.facebook.com/docs/reference/ios/current/class/FBSession