I’m using the following method to post a photo to Facebook. It works fine, however the image is set like this: NSURL *url = [NSURL URLWithString:@"http://www.example.com/image.png"];
I’d like to have the user select the image from their iPhone camera folder instead. How would I go about doing this – retrieving an image from the Photo Album and sending it from this method?
thanks for any help
- (void)apiGraphUserPhotosPost {
[self showActivityIndicator];
currentAPICall = kAPIGraphUserPhotosPost;
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
// Download a sample photo
NSURL *url = [NSURL URLWithString:@"http://www.example.com/image.png"];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[UIImage alloc] initWithData:data];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
img, @"picture",
nil];
[img release];
[[delegate facebook] requestWithGraphPath:@"me/photos"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
}
If you are done with selecting image from gallery?
if not then please follow the steps here in this blog entry, once you got the image, then simply do this way: