iOS FaceBook Connect Not Posting Picture
I am trying to implement Facebook 开发者_StackOverflow社区Connect into my program. More specifically I am trying to post a native UIImage to the user's Photos. I had a previous program that successfully implemented this. The user would upload the photo, then go to their Facebook page and accept the pending album. All photos thereafter would automatically load to the album. My problem is that this no longer works. When a photo is uploaded, there is no "pending album" anymore. (It does not work with my old program or the new one I am trying to implement.) Is there something that changed that I do not know about? Here is the code that I call after a valid session is established:
params = [NSMutableDictionary dictionaryWithObjectsAndKeys: img, @"picture",nil];
[facebook requestWithMethodName:@"photos.upload" andParams:params andHttpMethod:@"POST" andDelegate:self];
I also tried to implement it with the graphAPI as follows:
[facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];
and this does not work either. I was able to post on my old app until yesterday, but when I deleted the album that the app had originally created, the pictures stopped appearing on Facebook. Posting plain text and links to the wall works fine, but I cannot get the photos to post. Can anyone help me? Thank you in advance.
I'm new to the fb API, but I do have one working app. The requestWithGraphPath
method is non-blocking - meaning it will complete before the photo is actually uploaded. You'll know when the photo is finished uploading by implementing the following in your FBRequestDelegate
:
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error
(the upload request failed, during which you can inspect the NSError for the details as to why), or
- (void)request:(FBRequest *)request didLoad:(id)result
meaning it was successful.
Try NSLog(...)
-ing these two callbacks to see what is going on with your upload. If you're encountering a permissions or connectivity issue, you'll see it in the NSError
.
Hope this helps,
Scott Heaberlin
It turns out that the code was working correctly. I created a new Facebook account and the photos posted fine to that account. Why it is not working on my original Facebook account is a whole other question and probably more appropriate for Facebook support, not stack overflow. Thank you for the help scotth.
精彩评论