I need to post a photo (taken form the camera) in the users facebook wall with the location of the user.
Now, the facebook photo object has a field named place:
object containing id and name of Page associated with this location, and a location field containing geographic information such as latitude, longitude, country, and other fields (fields will vary based on geography and availability of information)
Now how do I get the place, attach it with the photo and upload it in the users wall.
This is my code for photo upload:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
resultImage, @"picture",
location, @"place",
nil];
[appDelegate.facebook requestWithGraphPath:@"me/photos"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
But, how do I get the location parameter here? Can anyone help? Thanks in advance.
The place object can only be a Facebook Page Id of the desired location according to this documentation. So, here is how I managed to get user’s location while uploading photo.
the current location is obtained by calling CLLocation Manager delegate and passed in the above method.
Next, if this request is successful, the place objects are inserted in a mutable array.
And then the photo uploading method is fired:
I have taken the first nearby place of the available check-ins (
[self.listOfPlaces objectAtIndex:0]) and now the app can successfully post photos with the users current nearby location.