Facebook 好友的 ID 无效
Invalid ID from Facebook friend
我正在尝试通过 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 大。当我将 link 放入浏览器时,我没有收到图像。我明白了:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: *****The id I retrieved******",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "B92Y7XevOaL"
}
}
查找错误时,我从 Facebook 看到了这个:
The Facebook page or group ID you’re using is not correct or invalid
我该如何解决这个错误?谢谢!
您不能在 API 的其他地方使用 taggable_friends
ID。但是,您可以将 request the picture
edge 作为 taggable_friends
请求的一部分,方法是将其添加到 parameters
数组中,即...
parameters: ["fields":"first_name, last_name, id, picture"]
我正在尝试通过 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 大。当我将 link 放入浏览器时,我没有收到图像。我明白了:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: *****The id I retrieved******",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "B92Y7XevOaL"
}
}
查找错误时,我从 Facebook 看到了这个:
The Facebook page or group ID you’re using is not correct or invalid
我该如何解决这个错误?谢谢!
您不能在 API 的其他地方使用 taggable_friends
ID。但是,您可以将 request the picture
edge 作为 taggable_friends
请求的一部分,方法是将其添加到 parameters
数组中,即...
parameters: ["fields":"first_name, last_name, id, picture"]