I have a local photo in my iPhone app, and I want to upload it to a specific album on Facebook dedicated to my app.
Problem: My app name ends with t
Ahh SWEET. I figured this one out with some good old-fashioned, straight-up tinkering.
Given that there is no real instruction on how to apply the 'album' value to an FBRequest, I hesitate to call it a bug, but either way I needed a different method - in this case, simply creating a generic Open Graph HTTP request and filling in all the image info.
There is no real downside to this approach; except that you can't use the requestForUploadPhoto: convenience method.
Here is my implementation of the correct method (removed 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];
}