2

I am implementing the Checkins Facebook Graph API using Facebook SDK. This is the code for Checkins

NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:accsstoken,@"access_token",@"253651184683030",@"place",@"I m here in this place",@"message",@"30.893075018178,75.821777459326",@"coordinates", nil];

        [FBRequestConnection startWithGraphPath:@"/me/checkins"
                                     parameters:dict
                                     HTTPMethod:@"POST"
                              completionHandler:^(
                                                  FBRequestConnection *connection,
                                                  id result,
                                                  NSError *error
                                                  ) {
                                  NSLog(@"Error...%@",error);

                              }];

When I tried this above code. It gives me following error:

error =         {
            code = 160;
            message = "(#160) Invalid coordinates.  Coordinates must contain at least latitude and longitude.";
            type = OAuthException;
        };

It gives the coordinates issue. Is there a different way to pass the coordinates parameters? Please help me out of this issue.

Nazik
  • 8,696
  • 27
  • 77
  • 123
Sudha Tiwari
  • 2,499
  • 26
  • 50
  • possible duplicate of [facebbok sdk Integrate interactive map in a post like Foursquare](http://stackoverflow.com/questions/22706323/facebbok-sdk-integrate-interactive-map-in-a-post-like-foursquare) – Sahil Mittal Apr 03 '14 at 10:47
  • Publishing `checkins` is deprecated. https://developers.facebook.com/docs/graph-api/reference/checkin#publishing – Sahil Mittal Apr 03 '14 at 10:48

2 Answers2

1

As far as I know checkins are deprecated and you should use post with place parameter.

And here is the link. Facebook SDK reference

Edit: For people who too lazy to check the link, there is the sample code from Facebook.

// Create an object
NSMutableDictionary<FBOpenGraphObject> *restaurant = [FBGraphObject openGraphObjectForPost];

// specify that this Open Graph object will be posted to Facebook
restaurant.provisionedForPost = YES;

// Add the standard object properties
restaurant[@"og"] = @{ @"title":@"Restaurant Name", @"type":@"restaurant.restaurant", @"description":@"a description", @"image":image };

// Add the properties restaurant inherits from place
restaurant[@"place"] = @{ @"location" : @{ @"longitude": @"-58.381667", @"latitude":@"-34.603333"} };

// Add the properties particular to the type restaurant.restaurant
restaurant[@"restaurant"] = @{@"category": @[@"Mexican"],
                         @"contact_info": @{@"street_address": @"123 Some st",
                                            @"locality": @"Menlo Park",
                                            @"region": @"CA",
                                            @"phone_number": @"555-555-555",
                                            @"website": @"http://www.example.com"}};

// Make the Graph API request to post the object
FBRequest *request = [FBRequest requestForPostWithGraphPath:@"me/objects/restaurant.restaurant"
                                                graphObject:@{@"object":restaurant}];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
  if (!error) {
    // Sucess! Include your code to handle the results here
    NSLog(@"result: %@", result);
    _objectID = [result objectForKey:@"id"];
    alertTitle = @"Object successfully created";
    alertText = [NSString stringWithFormat:@"An object with id %@ has been created", _objectID];
    [[[UIAlertView alloc] initWithTitle:alertTitle
                                message:alertText
                               delegate:self
                      cancelButtonTitle:@"OK!"
                      otherButtonTitles:nil] show];
  } else {
    // An error occurred, we need to handle the error
    // See: https://developers.facebook.com/docs/ios/errors   
  }
}];
Boran
  • 949
  • 10
  • 17
0

Checkins have been deprecated in favor of attaching place information to posts, or tagging places in Open Graph stories.

You can refer here

https://developers.facebook.com/docs/graph-api/reference/user/checkins/

Giya
  • 250
  • 3
  • 11