How to get user friends list from facebook graph API v2.0 higher in swift 3

By Lineesh K Mohan

I am developing a IOS entertainement application in swift 3 which requires to list the facebook friends of the user who login to that application.I am trying to fetch the available details of the user’s facebook friends using Facebook graph API. The version of the graph API is higher than 2.0.

Please find my code

func getFBFriendslist() {
    print("--> getFBFriendslist()")
    if((FBSDKAccessToken.current()) != nil){
        FBSDKGraphRequest(graphPath: "me/friends", parameters: ["fields" : "id,name"]).start(completionHandler: { (connection, result, error) -> Void in
            if (error == nil){
                print(result!)
            }
        })
    }
}

The output is

--> getFBFriendslist()
    data =     (
    );
    summary =     {
        "total_count" = 8;
    };

}

Here i am getting the data empty. I know that With Graph API v2.0 and above, calls to /me/friends return only the friends who also use the same app. These friends must have also granted the user_friends permission. But i don’t have much clarity in this

I also tried the taggable_friends API. I got the result, but i am not sure that it will give all the friends in the friends list. Also this API not giving the actual facebook id of the friends.

--> getFBFriendslist()
{
    data =     (
                {
            id = "xxxxxxxxxx";
            name = "xxxxxxxxx";
        },
                {
    paging =     {
        cursors =         {
            after = XXXXXXXX;
            before = XXXXXXXX;
        };
    };
}

Please suggest a proper way. Thanks in advance

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273