ios - Facebook SDK 使用 Graph API 1.0 版

标签 ios objective-c facebook facebook-graph-api

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
                          }
                      }];

最佳答案

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

[FBSettings enablePlatformCompatibility: YES];

这里所有的 FbRequests 都以 api v1.0 为目标是关于这个的官方文档: https://developers.facebook.com/docs/reference/ios/current/class/FBSettings/

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

[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
                      }
                  }];

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

参见 overrideVersionPartWith: 方法及其讨论

关于ios - Facebook SDK 使用 Graph API 1.0 版,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24046105/

相关文章:

Gatsby 中的 Facebook 插件(如按钮、页面插件、评论...)

ios - Phonegap SQLite 插件预填充数据库 iOS

ios - 键值观察不允许枚举上的 Switch 语句

ios - 异步声音

ios - <__NSCFDictionary : 0x1557f400> was mutated while being enumerated.'

javascript - 添加 Facebook 分享按钮未显示

c# - (OAuthException - #190) 格式错误的访问 token 异常

javascript - 软键盘可见时无法单击按钮

ios - 如何在快速调用 dismissViewController 后调用重新加载 TableView ?

ios - 添加 UITextField 作为 UITableViewCell 的 subview 在 IOS 6 中工作正常但在 IOS 7 中它不工作?