如何在iOS页面上以pageadmin的身份发布状态Feed?

时间:2014-10-01 12:29:03

标签: ios iphone xcode facebook facebook-graph-api

我想在我的Facebook页面上发布状态。状态应在Facebook上显示为页面状态,而不是来自任何用户名或我姓名的状态。

我尝试了下面的代码,

 NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:@"This is a check for page post message", @"message", nil];

/* make the API call */
[FBRequestConnection startWithGraphPath:@"/1521177224766299/feed"
                             parameters:params
                             HTTPMethod:@"POST"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error){
     if (result)
     {
         NSLog(@"Result %@", result);
     }
     else
     {
         NSLog(@"%@", error);
     }
 }];

消息状态已发布完成页面墙,但该状态来自我的名字。 但是,当我尝试使用page_id / feed POST查询并使用相同的参数@“这是我的状态”来自图api资源管理器页面的@“message”时,它从页面发布的状态不是来自我。

请帮忙。

2 个答案:

答案 0 :(得分:1)

 NSString *accesstoken=[NSString stringWithFormat:@"%@","here add your page access_token"];

    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            accesstoken, @"access_token",
                            postingString, @"message",

                           // @"http://www.real-timesports.com", @"link",


                            nil];

    FBRequest *requestToPost = [[FBRequest alloc] initWithSession:nil
                                                        graphPath:@"/me/feed"
                                                       parameters:params
                                                       HTTPMethod:@"POST"];


    NSLog(@"requestToPost==%@",requestToPost);

    FBRequestConnection *requestToPostConnection = [[FBRequestConnection alloc] init];
    [requestToPostConnection addRequest:requestToPost completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
     {


         NSLog(@"facebook result >> %@", result);


     }];
    [requestToPostConnection start];

答案 1 :(得分:0)

以下是完整答案

NSString *accesstoken = <Facebook_Page_Access_Token>

  NSDictionary*  params = [NSDictionary dictionaryWithObjectsAndKeys:
              @"Post heading", @"name",
              accesstoken, @"access_token",
              @"Type post message", @"message",
              @"Hyperlink to your post", @"link",
              @"Add description", @"description",
              @"Image url string", @"picture",
              nil];

    FBRequest *requestToPost = [[FBRequest alloc] initWithSession:nil
                                                        graphPath:@"/me/feed"
                                                       parameters:params
                                                       HTTPMethod:@"POST"];    

    FBRequestConnection *requestToPostConnection = [[FBRequestConnection alloc] init];
    [requestToPostConnection addRequest:requestToPost completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
     {
         if (!error) {             
             NSLog(@" %@", result);             
         }
         else
         {
             NSLog(@"%@", error);                        
         } 

     }];