【发布时间】:2016-04-11 08:51:01
【问题描述】:
请帮我解决以下错误:
Error Domain=com.facebook.sdk Code=5 "(null)" UserInfo={com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 2500;
"fbtrace_id" = "HkQ+T3pxGRU";
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
我在 facebook 上发布带有图片的消息时出现错误,我正在使用最新的 facebook sdk。
我正在使用以下代码:
-(void)posting
{
if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"]) {
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:@"hello hii how r u " forKey:@"message"];
[params setObject:UIImagePNGRepresentation(self.img_to_share.image) forKey:@"picture"];
[FBRequestConnection startWithGraphPath:@"me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (error)
{
//showing an alert for failure
NSLog(@"Unable to share the photo please try later.");
}
else
{
//showing an alert for success
NSLog(@"Shared the photo successfully");
}
}];
}
}
提前致谢,
【问题讨论】:
-
添加相关代码。
-
"An active access token must be used to query information about the current user."是用户登录fb吗? -
是的,用户已经登录 fb @AnilVarghese
标签: ios objective-c facebook facebook-graph-api facebook-ios-sdk