【发布时间】:2012-05-02 08:52:41
【问题描述】:
我已经使用了Graph API,并且已经成功登录Facebook并获得了好友列表。
现在我需要在墙上贴一条消息。怎么样?
【问题讨论】:
-
你是指朋友墙..还是你的墙?
标签: ios facebook facebook-graph-api
我已经使用了Graph API,并且已经成功登录Facebook并获得了好友列表。
现在我需要在墙上贴一条消息。怎么样?
【问题讨论】:
标签: ios facebook facebook-graph-api
使用 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];
}
【讨论】:
您还可以通过facebook"Hackbook for iOS"官方发布的demo了解如何发布墙以及iOS Facebook开发的其他必备实践
【讨论】:
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];
【讨论】:
如果您想在不显示对话框的情况下发布到您的 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.
你肯定会在用户登录并授权权限后这样做。
【讨论】: