I'm losing my mind over trying to get Facebook SDK for iPhone to upload UIImage. Here's what I'm doing:
1) Creating facebook property:
facebook = [[Facebook alloc] initWithAppId:@"111111111"];
2) Calling authorize:
[facebook authorize:[NSArray arrayWithObjects:@"publish_stream", nil] delegate:self];
3) Setting params:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:image, @"picture", nil];
4) Calling post:
[facebook requestWithMethodName:@"photos.upload" andParams:params andHttpMethod:@"POST" andD开发者_StackOverflow社区elegate:self];
When loging in I get the authorize dialog. When trying to upload I receive error 101, Invalid API Key. I've copied the key from FB, I've included it as shown above and I've also included it in .plist (fbAPI_KEY). What the hell am I still missing here? When asked to authorize it did show the name of the app just fine so the key must be correct. I can also post feeds and they appear on users wall, but images just won't upload.
That's a bit weird, I've got the exact same four lines of code which work fine for me. (Although, your app id is a bit shorter than it should be, mine is roughly twice that size).
One thing you may be forgetting about: when are you using each line? You should wait till each of the previous tasks is completed by using the facebook delegates, eg:
- (void)fbDidLogin; //part of the <FBSessionDelegate> protocol
Use these methods to control when the next part of the uploading process should occur, and check for errors along the way. You may be trying to send the photo before the login process has actually finished - use the delegate methods to prevent this.
I think you have to use graph API for uploading images
Check Out:
Ref URL: http://www.raywenderlich.com/1626/how-to-post-to-a-users-wall-upload-photos-and-add-a-like-button-from-your-iphone-app
Hope this helps....
精彩评论