我正在尝试打印我的facebook朋友的ID列表,但结果是空的。有什么想法吗?
FBSDKGraphRequest(graphPath:"me/friends", parameters:["fields": "id"]).start{(connection, result, err)in
if err != nil{
print("errorGraph")
return
}
else{
guard let data = result as? [String:Any] else { return }
let fbid = data["id"]
print("friendID:", fbid ?? "")
}}
答案 0 :(得分:0)
这有效:
var faceFriendIDs:Array<Any> = []
FBSDKGraphRequest(graphPath:"me/friends", parameters:["fields":"id"]).start{(connection, result, error)in
let resultDict = result as! NSDictionary
let data:NSArray = resultDict.object(forKey: "data") as! NSArray
for i in 0..<(data.count){
let valueDict:NSDictionary = data[i] as! NSDictionary
let id = valueDict.object(forKey: "id") as! String
self.faceFriendIDs.append(id)
}
print(self.faceFriendIDs)
}