【发布时间】:2016-10-06 07:27:42
【问题描述】:
我正在尝试运行一个功能来查看 Facebook 朋友,以便用户可以看到哪些当前正在使用该应用程序。我做了一些研究,发现了一些较旧的代码,但没有任何适用于 Swift 3 的代码。这是我现在所拥有的:
var fbRequestFriends: FBSDKGraphRequest = FBSDKGraphRequest.requestForMyFriends()
fbRequestFriends.startWithCompletionHandler{
(connection:FBSDKGraphRequestConnection!,result:AnyObject?, error:NSError!) -> Void in
if error == nil && result != nil {
print("Request Friends result : \(result!)")
} else {
print("Error \(error)")
}
}
它不会运行,因为 FBSDKGraphRequest 没有 requestForMyFriends。有谁知道如何更新它以便在 swift 3 上工作?
我也在 Facebook Docs 上找到了这个,但它都在 Obj C 中,但是在转换它时遇到了问题:
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/{friend-list-id}"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
【问题讨论】:
-
Facebook 更新了获取好友列表和其他 API 的政策。看看政策变化。
-
我做到了,我上面在 Obj C 中的代码似乎适用于其他已授权该应用程序的用户,我只是不知道如何将其转换为 swift。