我正在尝试使用 Facebook API 获取用户的朋友。这是我当前的代码:
FBSDKGraphRequest(graphPath:"/me/taggable_friends", parameters: ["fields":"first_name, last_name, id"]).start(completionHandler: { (connection, result, error) in
if error == nil {
if let results = result as? NSDictionary {
let data = results["data"]!
if let results = data as? [AnyObject] {
for result in results {
let object = result as AnyObject
let firstName = object.object(forKey: "first_name") as! String
let lastName = object.object(forKey: "last_name") as! String
let id = object.object(forKey: "id") as! NSString
print(id)
let facebookProfileUrl = "http://graph.facebook.com/\(id)/picture?width=10000"
如您所见,我正在检索朋友的个人资料。名字和姓氏可以正常检索,但我的个人资料图片有问题。朋友的id
id 似乎比我之前检索到的用户 id 大。当我将链接放入浏览器时,我没有收到图像。我明白了:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: *****The id I retrieved******",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "B92Y7XevOaL"
}
}
在查找错误时,我从 Facebook 看到:
您使用的 Facebook 页面或群组 ID 不正确或无效
如何解决此错误?谢谢!