【问题标题】:Post a message on Facebook wall using Graph API使用 Graph API 在 Facebook 墙上发布消息
【发布时间】:2012-05-02 08:52:41
【问题描述】:

我已经使用了Graph API,并且已经成功登录Facebook并获得了好友列表。

现在我需要在墙上贴一条消息。怎么样?

【问题讨论】:

标签: ios facebook facebook-graph-api


【解决方案1】:

使用 url 上墙发帖,并使用此方法上墙发帖

- (void)postToWall 
{

FBStreamDialog *dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.userMessagePrompt = @"Enter your message:";
dialog.attachment = [NSString stringWithFormat:@"{\"name\":\"Facebook Connect for iPhone\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone\",\"caption\":\"Caption\",\"description\":\"Description\",\"media\":[{\"type\":\"image\",\"src\":\"http://img40.yfrog.com/img40/5914/iphoneconnectbtn.jpg\",\"href\":\"http://developers.facebook.com/connect.php?tab=iphone/\"}],\"properties\":{\"another link\":{\"text\":\"Facebook home page\",\"href\":\"http://www.facebook.com\"}}}"];
[dialog show];
}

【讨论】:

    【解决方案2】:

    您还可以通过facebook"Hackbook for iOS"官方发布的demo了解如何发布墙以及iOS Facebook开发的其他必备实践

    【讨论】:

      【解决方案3】:

      NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:1];

      [variables setObject:@"this is a test message: postMeFeedButtonPressed" forKey:@"message"];
      
      FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"yourFriendFbID/feed" withPostVars:variables];
      
      SBJSON *parser = [[SBJSON alloc] init];
      NSDictionary *facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil];   
      [parser release];
      

      【讨论】:

        【解决方案4】:

        如果您想在不显示对话框的情况下发布到您的 FB 应用程序的墙上,您可以这样做

        NSString *message = @"some text";
        NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:message, @"message",nil];                          
        [fb requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self]; //fb here is the FaceBook instance.
        

        你肯定会在用户登录并授权权限后这样做。

        【讨论】:

          猜你喜欢
          • 2012-04-29
          • 1970-01-01
          • 1970-01-01
          • 2012-12-22
          • 1970-01-01
          • 1970-01-01
          • 2011-02-16
          • 2011-01-04
          • 1970-01-01
          相关资源
          最近更新 更多