在Facebook上发布问题

时间:2011-07-31 01:14:54

标签: objective-c ios facebook facebook-graph-api

当我通过我的应用程序登录Facebook时,一切正常,但我在发布到墙上时遇到了问题。

- (NSString *) postToFBWallStatus:(NSString *) status andSetDelegate: (id) delegate
{
    if (! isFBLoggedIn) 
    {
        return @"NotLoggedin";
    }

    NSString *message = status;
    NSLog(@"Appdelegate: postToFBWallStatus:andSetDelegate:");
    NSLog(@"to be delegate class: %@",[delegate class]);

    NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];

    ASIFormDataRequest *newRequest = [ASIFormDataRequest requestWithURL:url];
    [newRequest setPostValue:message forKey:@"message"];
    [newRequest setPostValue:@"" forKey:@"name"];
    [newRequest setPostValue:@"" forKey:@"caption"];
    [newRequest setPostValue:@"" forKey:@"description"];
    [newRequest setPostValue:@"" forKey:@"link"];
    [newRequest setPostValue:@"" forKey:@"picture"];
    [newRequest setPostValue:_accessToken forKey:@"access_token"];
    [newRequest setDidFinishSelector:@selector(postToWallFinished:)];
    [newRequest setDidFailSelector:@selector(postToWallFailed:)];
    [newRequest setDelegate:delegate];
    [newRequest startAsynchronous];

    return @"Loggedin";
}

当我发布到Facebook墙上时,我收到此消息:

error =     {
        message = "Invalid access token signature.";
        type = OAuthException;
    };

1 个答案:

答案 0 :(得分:0)

您必须使用用户的access_token将信息发布到他们的墙上。此外,用户需要允许API调用的publish_stream权限才能工作。对用户进行身份验证时,请将publish_stream添加到权限范围。