[英]Trouble retrieving list of facebook friends from json data in swift
I am using FBSDK in my Swift iOS application and currently I am trying to retrieve the list of friends who also use my app. 我在Swift iOS应用程序中使用FBSDK,当前正在尝试检索也使用我的应用程序的朋友列表。 I have two-three people who should show up but whenever I search the graphrequest result for friends it returns nil..
我有两个应该出现的人,但是每当我在graphrequest结果中搜索朋友时,它都会返回nil。
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: nil)
graphRequest.startWithCompletionHandler({ (connection, result:AnyObject!, error) -> Void in
if ((error) != nil)
{
// Process error
println("Error: \(error)")
}
else
{
//get Facebook ID
let faceBookID: NSString = result.valueForKey("id") as NSString
//get username
let userName : NSString = result.valueForKey("name") as NSString
//get facebook friends who use app
let friendlist: AnyObject = result.valueForKey("friends") as AnyObject
}
I have the "email", "user_friends", and "public_profile" permissions which should be enough to retrieve this information. 我具有“电子邮件”,“ user_friends”和“ public_profile”权限,这些权限应该足以检索此信息。 Any Ideas on what I am doing wrong??
关于我在做什么错的任何想法吗? this is doing my head in as my friend doing an android version has successfully got his working..
这是我的主意,因为我的朋友正在使用android版本,已经成功工作了。
My problem here was that I never Actually requested for the list of friends in my facebook graph request... 我的问题是我从未真正在我的Facebook图请求中请求朋友列表...
after replacing FBSDKGraphRequest(graphPath: "me", parameters: nil)
替换
FBSDKGraphRequest(graphPath: "me", parameters: nil)
with FBSDKGraphRequest(graphPath: "me?fields=id,name,friends", parameters: nil)
与
FBSDKGraphRequest(graphPath: "me?fields=id,name,friends", parameters: nil)
I was able to retrieve the list of friends because the response actually contained information for this. 我能够检索到朋友列表,因为响应实际上包含了有关此信息。 A very trivial mistake on my part.
我这是一个非常琐碎的错误。
In v2.0 of the Graph API, you must request the user_friends permission from each user.
在Graph API的v2.0中,您必须向每个用户请求user_friends权限。 user_friends is no longer included by default in every login.
默认情况下,不再在每个登录名中包含user_friends。 Each user must grant the user_friends permission in order to appear in the response to /me/friends.
每个用户必须授予user_friends权限才能出现在对/ me / friends的响应中。
see here : https://developers.facebook.com/bugs/1502515636638396/ 看到这里: https : //developers.facebook.com/bugs/1502515636638396/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.