Question

I'm trying to make a checkin in my app using Facebook, I've created the Story, Action and Object Type. The Facebook gave me the code:

NSMutableDictionary<FBGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:@"restaurant.restaurant"
                                        title:@"Sample Restaurant"
                                        image:@"https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png"
                                          url:@"http://samples.ogp.me/440002909390231"
                                  description:@"This place rocks"];;

[FBRequestConnection startForPostWithGraphPath:@"me/objects/restaurant.restaurant"
                               graphObject:object
                         completionHandler:^(FBRequestConnection *connection,
                                             id result,
                                             NSError *error) {
                             // handle the result
                         }];

But it's not working.

I've tried it too:

 NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                                                                 @"302184056577324", @"fb:app_id",
                                                                 @"restaurant.restaurant", @"og:type",
                                                                 @"http://samples.ogp.me/440002909390231", @"og:url",
                                                                 @"Sample Restaurant", @"og:title",
                                                                 @"https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png", @"og:image",
                                                                 @"This place rocks", @"og:description",
                                                                 @"1601 Willow Rd.", @"restaurant:contact_info:street_address",
                                                                 @"Menlo Park", @"restaurant:contact_info:locality",
                                                                 @"California", @"restaurant:contact_info:region",
                                                                 @"94025", @"restaurant:contact_info:postal_code",
                                                                 @"United States", @"restaurant:contact_info:country_name",
                                                                 @"brian@example.com", @"restaurant:contact_info:email",
                                                                 @"212-555-1234", @"restaurant:contact_info:phone_number",
                                                                 @"http://www.facebook.com", @"restaurant:contact_info:website",
                                                                 @"37.484828", @"place:location:latitude",
                                                                 @"-122.148283", @"place:location:longitude",
                                                                 nil
                                                                 ];
                                         /* make the API call */
                                         [FBRequestConnection startWithGraphPath:@"me/myapp:check_in"
                                                                      parameters:params
                                                                      HTTPMethod:@"POST"
                                                               completionHandler:^(
                                                                                   FBRequestConnection *connection,
                                                                                   id result,
                                                                                   NSError *error
                                                                                   ) {
                                                                   /* handle the result */
                                                                   DBLog(@"result: %@", result);
                                                                   DBLog(@"error: %@", error);
                                  }];

         }

Both code does not work, anyone could help me?

Thanks

Was it helpful?

Solution

Try this

[FBRequestConnection startForPostStatusUpdate:message 
                                    place:placeId 
                                     tags:nil 
                        completionHandler:
  ^(FBRequestConnection *connection, id result, NSError *error) {
       NSLog(@"Response....... \n\n %@  %@ %@",connection,result,error);
  }
];

OTHER TIPS

I found this way:

    [FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"]
                                   defaultAudience:FBSessionDefaultAudienceEveryone
                                      allowLoginUI:YES
                                 completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                     if (FBSession.activeSession.isOpen && !error) {

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

                                         // Post custom object
                                         [FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

                                             // create an Open Graph action
                                             id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
                                             [action setObject:[result objectForKey:@"id"] forKey:@"establishment"];

                                             // create action referencing user owned object
                                             [FBRequestConnection startForPostWithGraphPath:@"/me/myapp:check_in" graphObject:action completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                                 if(!error) {

                                                     success();

                                                 }else{

                                                     failure(error);

                                                 }
                                             }];

                                         }];



                                     }
                                 }];

But I've to change the action place to a custom establishment and this way will post twice on user's timeline one simple post and other check in

It's work, but not 100% correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top