使用 Parse 时如何获取所有 Facebook 好友的列表? [英] How to get list of all Facebook Friends when using Parse?

查看:13
本文介绍了使用 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 好友的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆