简体   繁体   English

来自Facebook朋友的无效ID

[英]Invalid ID from Facebook friend

I am trying to get the user's friends using Facebook API. 我正在尝试使用Facebook API来吸引用户的朋友。 Here is my current code: 这是我当前的代码:

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"

As you can see, I am retrieving the friends' profiles. 如您所见,我正在检索朋友的个人资料。 The first name and last name are retrieved fine, but I am having trouble with the profile picture. 可以很好地检索名字和姓氏,但是个人资料图片出现问题。 The id for the friend seems larger than the user id I retrieved earlier. 朋友的id似乎大于我之前检索的用户ID。 When I put the link into the browser, I don't receive an image. 当我将链接放入浏览器时,我没有收到图像。 I get this: 我得到这个:

{
   "error": {
      "message": "(#803) Some of the aliases you requested do not exist: *****The id I retrieved******",
      "type": "OAuthException",
      "code": 803,
      "fbtrace_id": "B92Y7XevOaL"
   }
}

When looking up the error, I see this from Facebook: 查找错误时,我从Facebook上看到了这一点:

The Facebook page or group ID you're using is not correct or invalid 您使用的Facebook页面或群组ID不正确或无效

How can I resolve this error? 如何解决此错误? Thanks! 谢谢!

You can't use taggable_friends IDs elsewhere in the API. 您不能在API的其他地方使用taggable_friends ID。 You can, however, request the picture edge as part of the taggable_friends request by adding it to your parameters array, ie.. 但是,您可以通过picture边缘添加到parameters数组(即。)中, picture边缘作为taggable_friends请求的一部分进行请求。

parameters: ["fields":"first_name, last_name, id, picture"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM