1

Following is the output when getFBfriends() is run in the code inside viewDidAppear below:

Output:

Result Dict: {
    data =     (
    );
    summary =     {
        "total_count" = 711;
    };
}
Found 0 friends

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.

Code:

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")
    }
}

}
user1406716
  • 9,565
  • 22
  • 96
  • 151
  • Is it true that -- "Apps are no longer able to retrieve the full list of a user’s friends (only those friends who have specifically authorized your app using the user_friends permission). This has been confirmed by Facebook as ‘by design’." I read it here: http://www.brianjcoleman.com/tutorial-get-facebook-friends-in-swift/ – user1406716 Apr 06 '15 at 06:44
  • Your permissions are correct, but try to login your app using another fb account you will get that user details in your data response. – Vikram Pote Apr 06 '15 at 07:22
  • @VikramPote - So I can get list of my friends ONLY who are using this app? and cannot get the entire list of all my friends? – user1406716 Apr 06 '15 at 07:23
  • yes ! you are right. – Vikram Pote Apr 06 '15 at 07:24
  • Ah, i feared that. ok got it, if you can add this as an answer - i will mark it as the answer – user1406716 Apr 06 '15 at 07:25

2 Answers2

4

Since v2.0 of the Graph API, you can only get the friends who authorized your App too. The result is correct, none of your friends authorized your App yet so it´s empty and only showing the total amount of friends.

More information: Get ALL User Friends Using Facebook Graph API - Android

Community
  • 1
  • 1
andyrandy
  • 72,880
  • 8
  • 113
  • 130
3

Your permissions are correct, but try to login your app using another fb account you will get that user details in your data response.

Vikram Pote
  • 5,433
  • 4
  • 33
  • 37