danielemm
danielemm

Reputation: 1696

Append coordinates (lat, lon) to a wall's post (iOS SDK)

I would to post a message on logged user's wall using iOS SDK. That's my code (it posts the messages successfully but lat, lon are not assigned). Any idea?

NSDictionary *coordinates = [NSDictionary dictionaryWithObjectsAndKeys:
                             [NSString stringWithFormat:@"%f",location.coordinate.latitude],@"latitude",
                             [NSString stringWithFormat:@"%f",location.coordinate.longitude],@"longitude", nil];

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               text,@"message",
                               [coordinates JSONString],@"coordinates",nil];

[FBRequest startWithGraphPath:@"me/feed"
                   parameters:params
                   HTTPMethod:@"POST"
            completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
            }];

Upvotes: 0

Views: 785

Answers (1)

Jason Clark
Jason Clark

Reputation: 1343

I have a couple of suggestions that may apply to your use case:

  • I am not aware of the ability to post a status with a coordinates field (it may be possible?); checkins and status updates take a place field, which is the ID of the place that you are attaching
  • As an aside, direct JSON encoding is not necessary when working with FBRequest, because it will encode what you give to it. The SDK works with dictionaries and arrays, essentially, and generates the JSON on your behalf.
  • The SDK has a helper method to request a list of places based on coordinates

It looks like this:

FBRequest *request = [FBRequest requestForPlacesSearchAtCoordinate:coordinate 
                                                    radiusInMeters:radius
                                                      resultsLimit:resultsLimit
                                                        searchText:searchText];
[request startWithCompletionHandler:...];

Hope this helps!

Upvotes: 2

Related Questions