1

我正在尝试在 Facebook 上分享。但是每次它请求发布权限时,它都会直接显示一个屏幕“您已授权给“AppName””。当我单击确定时。它把我带到了空白屏幕。

这是我的流程。1. 登录 Facebook 2. 请求发布权限。3. 发布到 Facebook 墙。

 [FBSession.activeSession requestNewPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
                                      defaultAudience:FBSessionDefaultAudienceFriends
                                    completionHandler:^(FBSession *session, NSError *error) {
                                        if (!error) {
                                            // Now have the permission
                                            [self publishStory];
                                        } else {
                                            // Facebook SDK * error handling *
                                            // if the operation is not user cancelled
                                            if (error.fberrorCategory != FBErrorCategoryUserCancelled) {
                                                [self presentAlertForError:error];
                                            }
                                        }
                                    }];
4

1 回答 1

0

你可以这样做,

在打开会话时指定发布帖子的权限

   NSArray  *permissions = [[NSArray alloc] initWithObjects:@"publish_actions",@"publish_stream",nil]; //permissions
  return [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session,FBSessionState state,NSError *error)


每当您想发布时,请这样做


  NSMutableDictionary *params = [[NSMutableDictionary alloc]initWithObjectsAndKeys:TextView.text, @"message",nil]; // set the formats
if([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] != NSNotFound)
{
    [FBRequestConnection startWithGraphPath:@"me/feed" parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
     {
         NSString *alertText;
         if(error)
         {
              //if error occurred

         }
         else
         {
             //successfull
         }

     }];

    }

 }


于 2013-08-05T05:17:05.913 回答