Reputation: 405
I'm confused as to how I use a location in a user's status. I see there is a place field, but I dont' know how to use it. The instructions just say an object, it doesn't specify at all what object it wants and in what format it wants. Can anyone give me a hand on posting a status with a location on it?
This is my code now:
- (void)postWithMessage:(NSString *)message image:(UIImage *)image location:(CLLocation *)location {
NSMutableDictionary *params = [NSMutableDictionary dictionary];
NSString *path = @"feed";
[params setObject:@"status" forKey:@"type"];
if (message && ![message isEqualToString:@""]) [params setObject:message forKey:@"message"];
if (image) {
path = @"me/photos";
[params setObject:@"photo" forKey:@"type"];
NSData *imageData = UIImagePNGRepresentation(image);
[params setObject:imageData forKey:@"source"];
}
if (location) {
//Stole this from iOS hackbook that Facebook wrote, but it wasn't helpful.
NSString *centerLocation = [[NSString alloc] initWithFormat:@"%f,%f", location.coordinate.latitude, location.coordinate.longitude];
[params setObject:centerLocation forKey:@"center"];
}
[facebook requestWithGraphPath:path andParams:params andHttpMethod:@"POST" andDelegate:self];
}
Upvotes: 16
Views: 2679
Reputation: 815
to test this you can try here https://developers.facebook.com/tools/ in the field paste this line example "search?q=spa&type=place¢er=40.7167,-74& distance=1000"
then you will see results like
{
"data": [
{
"location": {
"street": "221 Canal Street, Room 301",
"city": "New York",
"state": "NY",
"country": "United States",
"zip": "10013",
"latitude": 40.71761,
"longitude": -73.99933
},
"category": "Spas/beauty/personal care",
"name": "CiCi Beauty Spa",
"id": "180068255444372"
},
etc...
you can then post status like
("message", "im here guys"); // your message
("place", "180068255444372"); // the id of the place
in the tool field "me/feed"
in the tool change the method to POST then add field parameter for "message" and "place" to test it.
Upvotes: 0
Reputation: 1739
You have missed something, as i remember, the hackbook use the location to find the place id and then put it in parameter "place".
To do so, 1. you need to do a searching:
https://graph.facebook.com/search?
q=coffee&
type=place&
center=40.7167,-74&
distance=1000
//copy from facebook :]
Upvotes: 0
Reputation: 724
For adding a place, you need to provide place ID known by Facebook currently. For that you can get the nearest places which returns ID as well and then add the one which you want as the place.
Upvotes: 0
Reputation: 1108
The docs for creating a stream post list a parameter place
whose value is the Facebook Page ID of the location. You can find these place ids via search or querying the place FQL table.
You should also use the Graph api path me/feed
in this case.
Although unrelated to your question, in the if (image)
branch you add a parameter type
which isn't documented in the section on posting a photo.
Upvotes: 1