Facebook SDK使用Graph API版本1.0

Rob*_*Rob 4 facebook objective-c facebook-graph-api ios

Facebook图形API版本1.0和2.0之间存在一些我不太喜欢的差异,所以我想降级到图形API版本1.0.

任何想法如何做到这一点?

这是我正在使用的代码,它调用版本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
                          }
                      }];
Run Code Online (Sandbox Code Playgroud)

har*_*man 7

虽然上面的答案是正确的,你可以使用

[FBSettings enablePlatformCompatibility: YES];
Run Code Online (Sandbox Code Playgroud)

所有FbRequests目标api v1.0都是官方文档: https: //developers.facebook.com/docs/reference/ios/current/class/FBSettings/

如果你想针对使用graph api的v1.0的单个请求,你可以像这样指定它:

[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
                      }
                  }];
Run Code Online (Sandbox Code Playgroud)

以下是解释此https://developers.facebook.com/docs/reference/ios/current/class/FBRequest/的官方文档

见overrideVersionPartWith:方法与讨论


Dim*_*ima 6

这可以在FBRequest关卡中完成.

您需要自己创建FBRequest并使用overrideVersionPartWith:.

请记住,这仅适用于您的Facebook应用程序是在v2.0 API发布之前创建的.新的应用程序根本无法使用旧的API.

它看起来像这样:

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
                          }
                      }];
Run Code Online (Sandbox Code Playgroud)