本文介绍了如何在使用Parse时获取所有Facebook好友列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是在 viewDidAppear 中的代码中运行 getFBfriends()时的输出:
Following is the output when getFBfriends() is run in the code inside viewDidAppear below:
输出:
Result Dict: {
data = (
);
summary = {
"total_count" = 711;
};
}
Found 0 friends
total_count = 711是正确但是没有关于朋友的数据。我在这里错过了什么?认为权限是正确的。
The "total_count = 711" is correct but there is not data about the friends. What I am I missing here? Think the permissions are correct.
代码:
class SignUpViewController: UIViewController {
@IBOutlet weak var btn_signIn: UIButton!
@IBAction func action_btnSignIn(sender: AnyObject) {
var permissions = ["public_profile", "user_friends"]
println("in action_btnSignIn() of SignUpViewController")
var fbloginView:FBLoginView = FBLoginView(readPermissions: ["email", "public_profile", "user_friends"])
override func viewDidAppear(animated: Bool) {
if PFUser.currentUser() != nil {
println("User logged in, so launching Menu Screen")
//self.performSegueWithIdentifier("launchmenu", sender: self)
getDBfriends()
} else {
println("User NOT logged in")
}
}
func getDBfriends() {
var friendsRequest: FBRequest = FBRequest.requestForMyFriends()
friendsRequest.startWithCompletionHandler{(connection:FBRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
var resultdict = result as NSDictionary
println("Result Dict: \(resultdict)")
var data : NSArray = resultdict.objectForKey("data") as NSArray
for i in 0..<data.count {
let valueDict : NSDictionary = data[i] as NSDictionary
let id = valueDict.objectForKey("id") as String
println("the id value is \(id)")
}
var friends = resultdict.objectForKey("data") as NSArray
println("Found \(friends.count) friends")
}
}
}
推荐答案
您的权限是正确的,但尝试使用其他fb帐户登录您的应用,您将在数据响应中获得该用户详细信息。
Your permissions are correct, but try to login your app using another fb account you will get that user details in your data response.
这篇关于如何在使用Parse时获取所有Facebook好友列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!