Ahh SWEET. I thought this was one of the good old-fashioned, right craftsmen.
Given that there is no real instruction on how to apply the "album" value to FBRequest, I hesitate to call it a mistake, but in any case I need another method - in this case, just create a general Open Graph HTTP request and fill in all the information about image.
There is no real flaw in this approach; except that you cannot use the requestForUploadPhoto: method convenient.
Here is my implementation of the correct method (the remote code is commented out):
- (void)postPhotosToFacebook:(NSArray *)photos withAlbumID:(NSString *)albumID { UIImage *image = [photos lastObject]; // FBRequest *imageUploadRequest = [FBRequest requestForUploadPhoto:image]; // // [[imageUploadRequest parameters] setValue:albumID // forKey:@"album"]; // // DebugLog(@"imageUploadRequest parameters: %@",[imageUploadRequest parameters]); NSString *graphPath = [NSString stringWithFormat:@"%@/photos",albumID]; DebugLog(@"graphPath = %@",graphPath); NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys: image,@"picture", nil]; FBRequest *request = [FBRequest requestWithGraphPath:graphPath parameters:parameters HTTPMethod:@"POST"]; FBRequestConnection *connection = [[FBRequestConnection alloc] init]; [connection addRequest:request completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (!error) { DebugLog(@"Photo uploaded successfuly! %@",result); } else { DebugLog(@"Photo uploaded failed :( %@",error.userInfo); } }]; [connection start]; }
source share