1

我正在尝试通过我的应用程序中的 Facebook 功能创建共享。

按照 facebook 开发人员网站上的教程,我设置了我的项目并且登录工作正常。

但是,我无法使请求更多权限起作用。我需要向用户询问 publish_actions 权限,以便能够代表他从我的应用中发布。

例如,我有以下活动会话:

2014-06-02 10:44:56.729 facebook[68183:60b] activeSession: , expireDate: 2014-07-28 14:50:04 +0000,refreshDate: 2014-05-30 11:03:01 +0000,尝试RefreshDate :0001-12-30 00:00:00 +0000,权限:(已安装,“public_profile”)>

我尝试分享的代码是:

[FBRequestConnection startWithGraphPath:@"me/permissions"
     completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
          if (!error){
            NSDictionary *permissions= [(NSArray *)[result data] objectAtIndex:0];
            if (![permissions objectForKey:@"publish_actions"]){
              // Permission hasn't been granted, so ask for publish_actions
              [FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
                                                                            defaultAudience:FBSessionDefaultAudienceFriends
                                                                          completionHandler:^(FBSession *session, NSError *error) {
                 if (!error) {
                    if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound){
                       // Permission not granted, tell the user we will not share to Facebook
                       NSLog(@"Permission not granted, we will not share to Facebook.");
                 } else {
                      // Permission granted, publish the OG story
                      [self requestWithGraphPath:@"me/feed" andParams:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"http://www.in.gr",@"url",@"messageTitle",@"Titleos",@"description",@"description", nil] andHttpMethod:@"POST"];
                                                                                  }

                                                                              } else {
                                                                                  // An error occurred, we need to handle the error
                                                                                  // See: https://developers.facebook.com/docs/ios/errors
                                                                                  NSLog(@"Encountered an error requesting permissions: %@", error.description);
                                                                              }
                                                                          }];

                                  } else {
                                      // Permissions present, publish the OG story

                                      [self requestWithGraphPath:@"me/feed" andParams:[[NSMutableDictionary alloc] initWithObjectsAndKeys:@"http://www.in.gr",@"url",@"messageTitle",@"Titleos",@"description",@"description", nil] andHttpMethod:@"POST"];
                 }

            } else {
            // An error occurred, we need to handle the error
            // See: https://developers.facebook.com/docs/ios/errors
            NSLog(@"Encountered an error checking permissions: %@", error.description);
         }
}];

虽然我已经登录,但当我尝试请求附加权限时,它会再次要求我登录,而不是要求我批准附加权限。最重要的是,即使我再次登录,它也不会在所有 publish_actions 权限之后授予我。

如何成功请求发布所需的权限?

4

1 回答 1

1

事实证明,使用最新的 Facebook sdk(我认为是 3.1+),发布操作仅适用于已审核和提交的应用程序。

如果你想测试它,你必须从 facebook 仪表板制作你的应用程序的测试版本。

他们现在让它有点烦人。确保您已在 Facebook 应用程序仪表板上正确设置所有内容,否则在尝试通过您的应用程序共享内容时会出错。

于 2014-06-04T11:41:26.643 回答