我搜索了所有地方,但没有得到如何实现的单个提示。...我也得到了一些代码,但是它没有用...有人可以建议我使用任何教程或示例代码来做到这一点!!!提前致谢
我正在尝试以下代码::

-(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];
                          }];
}

最佳答案

为了发布到朋友的墙上,您需要向/{friend_id}/feed发出请求。但是,Facebook具有disabled posting to friends' wall since February 6, 2013


  删除通过Graph API发布到朋友墙的功能
  
  我们将删除通过图表发布到用户朋友的墙上的功能
  API。具体来说,针对[user_id] / feed的帖子,其中[user_id]是
  与会话用户不同,或stream.publish调用,其中
  target_id用户不同于会话用户,将失败。如果你
  希望允许人们发布到朋友的时间表中,调用
  供稿对话框。通过用户提及标记包括朋友的故事
  动作标签将显示在朋友的时间轴上(假设
  朋友批准标签)。有关更多信息,请参见此博客文章。

关于iphone - 如何在iPhone中使用fbrequest以编程方式在Facebook friend 墙上发布信息?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16167314/

10-10 22:04
查看更多