iphone:FBConnect自动发布到用户墙

时间:2010-04-30 11:13:03

标签: iphone objective-c fbconnect

我想从我的iphone应用程序自动发布到用户墙(没有“发布”“跳过”对话框)。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

应在实现FBSessionDelegateFBRequestDelegate的类中调用以下内容:

Facebook *_facebook = [[Facebook alloc] initWithAppId:kAppId];
NSArray *_permissions =  [[NSArray arrayWithObjects:
                           @"read_stream", @"offline_access",nil] retain];
[_facebook authorize:_permissions delegate:self];

这就是对fb post的调用(应该在同一个类中使用):

NSString *message = @"This is the message I want to post";
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               message, @"message",
                               nil];

[_facebook requestWithMethodName:@"stream.publish"
                       andParams:params
                   andHttpMethod:@"POST"
                     andDelegate:self];

如果您想在其他用户的墙上发布消息,则应在params字典中包含“uid”参数。请咨询http://developers.facebook.com/docs/reference/rest/stream.publish/

P.S。 iPhone Facebook connect SDK示例代码中有所有必要的示例,请不要害怕调查;)