Facebook Publish_action无法发布

时间:2015-01-05 12:18:18

标签: ios objective-c iphone facebook-graph-api facebook-sdk-4.0

您好我试图在我的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)用户尚未授权应用程序执行此操作”;

2 个答案:

答案 0 :(得分:0)

来自error code

您似乎没有permission for share

请参阅facebook error code here

获取sharing permission,请参阅this page

答案 1 :(得分:0)

如果您未经审核即使用publish_actions权限,则会引发此错误。出于测试目的,您始终可以在developers.facebook.com中的MyApp的Roles列中创建测试用户,然后使用它。