我正在使用最新的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