Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Facebook Status Location

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];
}
like image 737
Homeschooldev Avatar asked Feb 01 '12 15:02

Homeschooldev


People also ask

Why does my Facebook status show wrong location?

If you see a location that you don't recognize, first check if it's related to your mobile device. Often, when signing in through a mobile device, you're routed through an IP address that doesn't actually reflect your actual location.


1 Answers

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.

like image 152
Richard Barnett Avatar answered Oct 13 '22 00:10

Richard Barnett