Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SDK use Graph API version 1.0

There are some differences between the Facebook graph API versions 1.0 and 2.0 that I'm not so fond of so I would like to downgrade to the graph API version 1.0.

Any ideas how to do this?

Here's the code I'm using right now, which makes a call to version 2.0:

[FBRequestConnection startWithGraphPath:@"/me/friends"
                             parameters:[NSDictionary dictionaryWithObjectsAndKeys:@"20", @"limit", nil]
                             HTTPMethod:@"GET"
                      completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                          if (!error) {
                              // Sucess! Include your code to handle the results here
                              NSLog(@"***** user friends with params: %@", result);
                          } else {
                              // An error occurred, we need to handle the error
                          }
                      }];
like image 373
Rob Avatar asked Dec 11 '22 05:12

Rob


2 Answers

while the above answer is correct you can use

[FBSettings enablePlatformCompatibility: YES];

And all FbRequests target api v1.0 here is the official documentation about this: https://developers.facebook.com/docs/reference/ios/current/class/FBSettings/

And if you want to target individual request that use of v1.0 of graph api you can specify it like this:

[FBRequestConnection startWithGraphPath:@"v1.0/me/friends"
                         parameters:[NSDictionary dictionaryWithObjectsAndKeys:@"20", @"limit", nil]
                         HTTPMethod:@"GET"
                  completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                      if (!error) {
                          // Sucess! Include your code to handle the results here
                          NSLog(@"***** user friends with params: %@", result);
                      } else {
                          // An error occurred, we need to handle the error
                      }
                  }];

And here is the official docs that explains this https://developers.facebook.com/docs/reference/ios/current/class/FBRequest/

See overrideVersionPartWith: method and Discussion of it

like image 102
hariszaman Avatar answered Dec 26 '22 06:12

hariszaman


This can be accomplished at the FBRequest level.

You need to create the FBRequest yourself and use overrideVersionPartWith:.

Keep in mind this will only work if your Facebook app was created before the v2.0 API was released. Newer apps are blocked from using the old API at all.

It will look something like this:

FBRequest *request = [FBRequest requestWithGraphPath:@"/me/friends"
                                          parameters:[NSDictionary dictionaryWithObjectsAndKeys:@"20", @"limit", nil]
                                          HTTPMethod:@"GET"];
[request overrideVersionPartWith:@"v1.0"];

[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                          if (!error) {
                              // Success! Include your code to handle the results here
                              NSLog(@"***** user friends with params: %@", result);
                          } else {
                              // An error occurred, we need to handle the error
                          }
                      }];
like image 43
Dima Avatar answered Dec 26 '22 04:12

Dima