我使用过Graph API,并已成功登录Facebook并获取好友列表。
现在我需要在墙上发布消息。怎么样?
答案 0 :(得分:1)
使用网址在墙上发布,并使用此方法在墙上发布
- (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];
}
答案 1 :(得分:0)
您还可以通过facebook "Hackbook for iOS"官方发布的演示版了解如何为iOS Facebook开发发布墙和其他基本练习
答案 2 :(得分:0)
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];
答案 3 :(得分:0)
如果你想发布你的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.
并且肯定会在用户登录并授权权限后执行此操作。