我正在使用最新的Facebook iOS SDK 3.1.1 ,同时尝试在朋友墙上张贴UIImage我得到错误5(错误:HTTP状态码:403)。Facebook iOS SDK 3.1在朋友墙上张贴图片错误
如果我尝试在我的墙上发布图片,但它的效果不错,但不是我的朋友之一。
我的代码: 1.张贴我检查用户是否具有正确的权限之前,当他做我正在做
-(void)postImageOnFriendsWall:(UIImage*)image FriendsArray:(NSArray*)friends
{
// if we don't have permission to announce, let's first address that
if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound)
{
[FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error)
{
if (!error)
{
// re-call assuming we now have the permission
[self postImageOnFriendsWall:image FriendsArray:friends];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}];
}
else
{
// can post image
for (id<FBGraphUser> user in friends)
{
NSString *userID = user.id;
NSLog(@"trying to post image of %@ wall",userID);
NSMutableDictionary *postVariablesDictionary = [[NSMutableDictionary alloc] init];
[postVariablesDictionary setObject:UIImagePNGRepresentation(image) forKey:@"picture"];
[postVariablesDictionary setObject:@"my image" forKey:@"message"];
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/photos",userID] parameters:postVariablesDictionary HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
if (error)
{
//showing an alert for failure
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Facebook" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else
{
//showing an alert for success
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Facebook" message:@"Shared the photo successfully" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}];
}
}
}
提,如果我改变
startWithGraphPath:[NSString stringWithFormat:@"%@/photos",userID]
至
startWithGraphPath:[NSString stringWithFormat:@"me/photos",userID]
其工作o ķ。
我在做什么错? 我一直在寻找答案,但没有任何帮助。 谢谢!
哇! 谢谢你!我甚至不能说我多么感激它!它工作得很好! 为我节省了很多时间:) – user1526725
一点都不,你应该接受答案,如果它帮助你。点击票数附近的复选标记。 – Stas