如何在iOS的朋友墙上发布消息?

时间:2013-11-20 13:32:33

标签: ios iphone facebook-graph-api ios5 facebook-sdk-3.0

我正在尝试使用requestWithGraphPath:parameters:HTTPMethod:方法在朋友的墙上发布消息,但它不起作用。

这是我的代码,

-(void)shareAdOnFacebook
{
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setObject:@"Test post with silent authentication" forKey:@"message"];
    [params setObject:@"link" forKey:@"type"];
    [params setObject:@"http://yoursite.com" forKey:@"link"];
    [params setObject:@"Link description" forKey:@"description"];

    NSString *graphPath = @"[user_id]/feed";
    [FBRequest requestWithGraphPath:graphPath parameters:params HTTPMethod:@"POST"];
}

没有错误,但它没有发布任何内容。我正试图让它在iOS5及更高版本上运行。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

NSArray *permissions =[NSArray arrayWithObjects:@"publish_actions",@"publish_stream",@"manage_friendlists", nil];

[[FBSession activeSession] reauthorizeWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends
                                           completionHandler:^(FBSession *session, NSError *error) {
                                               /* handle success + failure in block */
                                           }];

来自:Referance