我正在使用 Facebook SDK 3.0 登录用户,并且我成功获得了它的 FB id 和 FB 会话令牌。
`NSDictionary<FBGraphUser> *user.id` (FB ID)
和
[FBSession.activeSession accessToken]
(FB会话令牌)
现在我想在我的应用程序中赞一个帖子。所以我正在创建一个 POST 请求并像这样传递参数
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/og.likes",@"34856345..."]] cachePolicy:NO timeoutInterval:5.0];
[urlRequest addValue:@"BAAGjjgD8bhUBAM73jzkpy23zlHo7e8ZAqPaOGvbxU..." forHTTPHeaderField:@"access_token"];
[urlRequest addValue:myshareLink forHTTPHeaderField:@"object"];
[urlRequest setHTTPMethod:@"POST"];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self startImmediately:YES];
[theConnection autorelease];
但我收到了这个错误
result:{"error":{"message":"An access token is required to request this resource.","type":"OAuthException","code":104}}
但是如果我使用 CURL 命令中的相同访问令牌和用户 ID,它会成功发布。
curl -X POST -F 'access_token=BAAGjjgD8bhUBAE8XmogjJZAZAPyJ8SUyxkllJQ...' -F 'object=http://xyz.com/abc/gallery.php#pic/pic2/' https://graph.facebook.com/732../og.likes
请一些帮助我弄清楚我错过了什么。
谢谢