发布在Facebook页面作为管理员iOS Facebook SDK



我需要在我自己的fanpage作为管理员的帖子。我创建了这个代码跳转,传递页面的id"fbPageID"将在该页面上留下帖子,但它实际上在我的个人资料上留下了帖子。

NSArray *publishPerms = @[@"manage_pages",@"publish_actions", @"publish_stream"];
[FBSession openActiveSessionWithPublishPermissions:publishPerms     defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:NO completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
        if (session.isOpen) {
            [FBRequestConnection startForPostStatusUpdate:self.textBox.text place:fbPageID tags:nil completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                if (error){
                    NSLog(@"error %@",error);
                }
                else{
                    NSLog(@"POSTED %@",result);
                }
            }];
        }
        else{
            NSLog(@"session not open");
        }

这对用户Facebook上的帖子很有帮助。

  1. 步骤1 -在项目中导入FBSDK

  2. 步骤2 -登录认证

    NSDictionary *params = @{
    @"message": @"This is a test message",
                             };
    /* make the API call */
    FBSDKGraphRequest *request_ = [[FBSDKGraphRequest alloc]
                                  initWithGraphPath:@"/me/feed"
                                  parameters:params
                                  HTTPMethod:@"POST"];
    [request_ startWithCompletionHandler:^(FBSDKGraphRequestConnection   *connection,
                                          id result,
                                          NSError *error) {
        // Handle the result
    }];
    

相关内容

  • 没有找到相关文章

最新更新