I'm trying to print a list of my facebook friends' id but the result is empty. Any ideas?
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 ?? "")
}}
This works:
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)
}