0

我搜索了每一个地方,但没有得到一个提示如何做到这一点......我也得到了一些代码,但它不起作用......任何人都可以建议我任何教程或示例代码来做到这一点!在此先感谢我正在尝试以下代码::

-(void)inviteFriend:(CustomButton *)sender
{

    NSString *str=[NSString stringWithFormat:@"%@/feed",sender.inviteUserId];
    if (FBSession.activeSession.isOpen)
    {
        //UIImage *image = [UIImage imageNamed:@"testImage.png"];

        hudApp = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        hudApp.labelText = @"Page Sharing...";
        [self performSelector:@selector(timeout:) withObject:nil afterDelay:60*5];

        // NSString *fbMessage = [NSString stringWithFormat:@"test"];
        NSString *fbMessage = @"hello testing";


        NSMutableDictionary* params=[NSDictionary dictionaryWithObjectsAndKeys:fbMessage, @"message", FBSession.activeSession.accessToken, @"access_token", nil];

        NSLog(@"feed::%@",str);

        [FBRequestConnection startWithGraphPath:str
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection, id result,NSError *error) {
                                  NSLog(@"result::%@",result);


                 if(error)
                 {
                  NSLog(@"fail : %@",error.localizedDescription);
                hudApp.labelText = [NSString stringWithFormat:@"%@",error.localizedDescription];
                                  }
                                  else
                                  {
                                      NSLog(@"Success facebook post");
                                      hudApp.labelText = [NSString stringWithFormat:@"Success"];
                                      // txtView.text = @"success";
                                      NSLog(@"success");
                                  }

                                  hudApp.mode = MBProgressHUDModeCustomView;
                                  [self performSelector:@selector(dismissHUD:) withObject:nil afterDelay:1.0];
                              }];
    }
    else
    {
        NSArray *permissions = [NSArray arrayWithObject:@"publish_stream"];
        [FBSession openActiveSessionWithPermissions:permissions allowLoginUI:YES
                          completionHandler:^(FBSession *session, FBSessionState state,NSError *error) {
                                      NSLog(@"session.permissions ? : %@", session.permissions);
                                      [self sessionDoneForPageShare:session state:state error:error withuserid:str];
                                  }
         ];
    }


}


-(void)sessionDoneForPageShare:(FBSession *)session state:(FBSessionState)state error:(NSError *)error withuserid :(NSString *)usreid
{
    //UIImage *image = [UIImage imageNamed:@"testImage.png"];

    NSLog(@"feed::%@",usreid);
    hudApp = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hudApp.labelText = @"Page Sharing...";
    [self performSelector:@selector(timeout:) withObject:nil afterDelay:60*5];

    //NSString *fbMessage = [NSString stringWithFormat:@"test"];
    NSString *fbMessage = @"hello testing";

    NSLog(@"State : %d **** Facebook Message : %@",state,fbMessage);

   // NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys: fbMessage, @"message", nil];

    NSMutableDictionary* params=[NSDictionary dictionaryWithObjectsAndKeys:fbMessage, @"message", FBSession.activeSession.accessToken, @"access_token", nil];

    [FBRequestConnection startWithGraphPath:usreid
                         parameters:params
                         HTTPMethod:@"POST"
                  completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

                              if(error)
                              {
                                  NSLog(@"fail : %@",error.localizedDescription);
                                  // txtView.text = [NSString stringWithFormat:@"%@",error.localizedDescription];
                                  NSLog(@"%@",[NSString stringWithFormat:@"%@",error.localizedDescription]);
                                  hudApp.labelText = [NSString stringWithFormat:@"%@",error.localizedDescription];
                              }
                              else
                              {
                                  NSLog(@"Success facebook post");
                                  hudApp.labelText = [NSString stringWithFormat:@"Success"];
                                  //txtView.text = @"success";
                                  NSLog(@"success");
                              }

                              hudApp.mode = MBProgressHUDModeCustomView;
                              [self performSelector:@selector(dismissHUD:) withObject:nil afterDelay:1.0];
                          }];
}
4

1 回答 1

1

为了在朋友的墙上发帖,您需要向/{friend_id}/feed. 但是,自 2013 年 2 月 6 日起,Facebook 已禁止在朋友墙上发帖

移除通过 Graph API 向朋友墙发帖的功能

我们将删除通过 Graph API 向用户朋友的墙发帖的功能。具体来说,针对 [user_id]/feed 的 [user_id] 与会话用户不同的帖子,或 target_id 用户与会话用户不同的 stream.publish 调用将失败。如果您想允许人们发布到他们朋友的时间线,请调用提要对话框。通过用户提及标签或动作标签包含朋友的故事将显示在朋友的时间线上(假设朋友批准标签)。有关详细信息,请参阅此博客文章。

于 2013-04-23T11:45:22.377 回答