How can I get my Facebook friends profile picture, name and gender





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-5















Hello I am working on an IOS app that login into facebook and get all your facebook friends profile picture, name and gender, which is basically like tinder but based on facebook friends
My question is how to get my friends profile picture name and gender










share|improve this question




















  • 1





    You can't. You can only get info about people that granted permission to your app

    – WizKid
    Nov 16 '18 at 18:10











  • idownvotedbecau.se/noresearch

    – luschn
    Nov 17 '18 at 8:05











  • "how to do xy" is too broad for stackoverflow. wizkid is right, and in your next question you should add what you have tried so far, and tell exactly where you got stuck.

    – luschn
    Nov 17 '18 at 8:07


















-5















Hello I am working on an IOS app that login into facebook and get all your facebook friends profile picture, name and gender, which is basically like tinder but based on facebook friends
My question is how to get my friends profile picture name and gender










share|improve this question




















  • 1





    You can't. You can only get info about people that granted permission to your app

    – WizKid
    Nov 16 '18 at 18:10











  • idownvotedbecau.se/noresearch

    – luschn
    Nov 17 '18 at 8:05











  • "how to do xy" is too broad for stackoverflow. wizkid is right, and in your next question you should add what you have tried so far, and tell exactly where you got stuck.

    – luschn
    Nov 17 '18 at 8:07














-5












-5








-5








Hello I am working on an IOS app that login into facebook and get all your facebook friends profile picture, name and gender, which is basically like tinder but based on facebook friends
My question is how to get my friends profile picture name and gender










share|improve this question
















Hello I am working on an IOS app that login into facebook and get all your facebook friends profile picture, name and gender, which is basically like tinder but based on facebook friends
My question is how to get my friends profile picture name and gender







facebook facebook-graph-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '18 at 8:06









luschn

58.7k580101




58.7k580101










asked Nov 16 '18 at 17:38









JohnJohn

45




45








  • 1





    You can't. You can only get info about people that granted permission to your app

    – WizKid
    Nov 16 '18 at 18:10











  • idownvotedbecau.se/noresearch

    – luschn
    Nov 17 '18 at 8:05











  • "how to do xy" is too broad for stackoverflow. wizkid is right, and in your next question you should add what you have tried so far, and tell exactly where you got stuck.

    – luschn
    Nov 17 '18 at 8:07














  • 1





    You can't. You can only get info about people that granted permission to your app

    – WizKid
    Nov 16 '18 at 18:10











  • idownvotedbecau.se/noresearch

    – luschn
    Nov 17 '18 at 8:05











  • "how to do xy" is too broad for stackoverflow. wizkid is right, and in your next question you should add what you have tried so far, and tell exactly where you got stuck.

    – luschn
    Nov 17 '18 at 8:07








1




1





You can't. You can only get info about people that granted permission to your app

– WizKid
Nov 16 '18 at 18:10





You can't. You can only get info about people that granted permission to your app

– WizKid
Nov 16 '18 at 18:10













idownvotedbecau.se/noresearch

– luschn
Nov 17 '18 at 8:05





idownvotedbecau.se/noresearch

– luschn
Nov 17 '18 at 8:05













"how to do xy" is too broad for stackoverflow. wizkid is right, and in your next question you should add what you have tried so far, and tell exactly where you got stuck.

– luschn
Nov 17 '18 at 8:07





"how to do xy" is too broad for stackoverflow. wizkid is right, and in your next question you should add what you have tried so far, and tell exactly where you got stuck.

– luschn
Nov 17 '18 at 8:07












1 Answer
1






active

oldest

votes


















-1














You need to ask the read permission for email and profile_picture to FBSDKLogin Manager



FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"]



Also in GraphRequest ask for fields you require



FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"])



Please see below code for reference



btn_Facebook.addTarget(self, action: #selector(handleCustomFBLogin), for: .touchUpInside)

///FACEBOOK LOGIN
func handleCustomFBLogin(sender:UIButton!){
FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self) { (result, err) in
if(err != nil){
print("Custom FB Login Failed")
return
}
//print(result?.token.tokenString)
self.showEmailAddress()
}
}

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!){
if(error != nil){
print(error)
return
}
print("Successfully Logged in using facebook")
showEmailAddress()
}

func showEmailAddress(){
let accesstoken = FBSDKAccessToken.current();
guard let accessTokenString = accesstoken?.tokenString else {return}

FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"]).start { (connection, result, err) in
if(err != nil){
print("Failed to start GraphRequest", err ?? "")
return
}
print(result ?? "")
if(result != nil){
self.sendDetailsForFacebookLogin(result: result as! NSDictionary)
}else{
MyCustomAlert.sharedInstance.ShowAlert(vc: self, myTitle: StringClass.sharedInstance.lcStr_loginfailedcaps, myMessage: StringClass.sharedInstance.lcStr_plsTryAgain)
}

}

}

func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!){
print("Logged out of Facebook")
}

func sendDetailsForFacebookLogin(result:NSDictionary){
//print(result)

var theemail:String = ""
var thefname:String = ""
var thelname:String = ""
var thedob:String = ""
var thecity:String = ""
var thereunder:String = “”

if result["email"] != nil {
theemail = (result.value(forKey: "email") as? String)!
}
if result["first_name"] != nil {
thefname = (result.value(forKey: "first_name") as? String)!
}
if result["last_name"] != nil {
thelname = (result.value(forKey: "last_name") as? String)!
}
if result["birthday"] != nil {
thedob = (result.value(forKey: "birthday") as? String)!
}
if result["city"] != nil {
thecity = (result.value(forKey: "city") as? String)!
}
if result[“gender”] != nil {
thegender = (result.value(forKey: “gender”) as? String)!
}

let picDict:NSDictionary = result.value(forKey: "picture") as! NSDictionary
let dataDict:NSDictionary = picDict.value(forKey: "data") as! NSDictionary
let theimg:String = dataDict.value(forKey: "url") as! String



}





share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342825%2fhow-can-i-get-my-facebook-friends-profile-picture-name-and-gender%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    -1














    You need to ask the read permission for email and profile_picture to FBSDKLogin Manager



    FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"]



    Also in GraphRequest ask for fields you require



    FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"])



    Please see below code for reference



    btn_Facebook.addTarget(self, action: #selector(handleCustomFBLogin), for: .touchUpInside)

    ///FACEBOOK LOGIN
    func handleCustomFBLogin(sender:UIButton!){
    FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self) { (result, err) in
    if(err != nil){
    print("Custom FB Login Failed")
    return
    }
    //print(result?.token.tokenString)
    self.showEmailAddress()
    }
    }

    func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!){
    if(error != nil){
    print(error)
    return
    }
    print("Successfully Logged in using facebook")
    showEmailAddress()
    }

    func showEmailAddress(){
    let accesstoken = FBSDKAccessToken.current();
    guard let accessTokenString = accesstoken?.tokenString else {return}

    FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"]).start { (connection, result, err) in
    if(err != nil){
    print("Failed to start GraphRequest", err ?? "")
    return
    }
    print(result ?? "")
    if(result != nil){
    self.sendDetailsForFacebookLogin(result: result as! NSDictionary)
    }else{
    MyCustomAlert.sharedInstance.ShowAlert(vc: self, myTitle: StringClass.sharedInstance.lcStr_loginfailedcaps, myMessage: StringClass.sharedInstance.lcStr_plsTryAgain)
    }

    }

    }

    func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!){
    print("Logged out of Facebook")
    }

    func sendDetailsForFacebookLogin(result:NSDictionary){
    //print(result)

    var theemail:String = ""
    var thefname:String = ""
    var thelname:String = ""
    var thedob:String = ""
    var thecity:String = ""
    var thereunder:String = “”

    if result["email"] != nil {
    theemail = (result.value(forKey: "email") as? String)!
    }
    if result["first_name"] != nil {
    thefname = (result.value(forKey: "first_name") as? String)!
    }
    if result["last_name"] != nil {
    thelname = (result.value(forKey: "last_name") as? String)!
    }
    if result["birthday"] != nil {
    thedob = (result.value(forKey: "birthday") as? String)!
    }
    if result["city"] != nil {
    thecity = (result.value(forKey: "city") as? String)!
    }
    if result[“gender”] != nil {
    thegender = (result.value(forKey: “gender”) as? String)!
    }

    let picDict:NSDictionary = result.value(forKey: "picture") as! NSDictionary
    let dataDict:NSDictionary = picDict.value(forKey: "data") as! NSDictionary
    let theimg:String = dataDict.value(forKey: "url") as! String



    }





    share|improve this answer






























      -1














      You need to ask the read permission for email and profile_picture to FBSDKLogin Manager



      FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"]



      Also in GraphRequest ask for fields you require



      FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"])



      Please see below code for reference



      btn_Facebook.addTarget(self, action: #selector(handleCustomFBLogin), for: .touchUpInside)

      ///FACEBOOK LOGIN
      func handleCustomFBLogin(sender:UIButton!){
      FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self) { (result, err) in
      if(err != nil){
      print("Custom FB Login Failed")
      return
      }
      //print(result?.token.tokenString)
      self.showEmailAddress()
      }
      }

      func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!){
      if(error != nil){
      print(error)
      return
      }
      print("Successfully Logged in using facebook")
      showEmailAddress()
      }

      func showEmailAddress(){
      let accesstoken = FBSDKAccessToken.current();
      guard let accessTokenString = accesstoken?.tokenString else {return}

      FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"]).start { (connection, result, err) in
      if(err != nil){
      print("Failed to start GraphRequest", err ?? "")
      return
      }
      print(result ?? "")
      if(result != nil){
      self.sendDetailsForFacebookLogin(result: result as! NSDictionary)
      }else{
      MyCustomAlert.sharedInstance.ShowAlert(vc: self, myTitle: StringClass.sharedInstance.lcStr_loginfailedcaps, myMessage: StringClass.sharedInstance.lcStr_plsTryAgain)
      }

      }

      }

      func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!){
      print("Logged out of Facebook")
      }

      func sendDetailsForFacebookLogin(result:NSDictionary){
      //print(result)

      var theemail:String = ""
      var thefname:String = ""
      var thelname:String = ""
      var thedob:String = ""
      var thecity:String = ""
      var thereunder:String = “”

      if result["email"] != nil {
      theemail = (result.value(forKey: "email") as? String)!
      }
      if result["first_name"] != nil {
      thefname = (result.value(forKey: "first_name") as? String)!
      }
      if result["last_name"] != nil {
      thelname = (result.value(forKey: "last_name") as? String)!
      }
      if result["birthday"] != nil {
      thedob = (result.value(forKey: "birthday") as? String)!
      }
      if result["city"] != nil {
      thecity = (result.value(forKey: "city") as? String)!
      }
      if result[“gender”] != nil {
      thegender = (result.value(forKey: “gender”) as? String)!
      }

      let picDict:NSDictionary = result.value(forKey: "picture") as! NSDictionary
      let dataDict:NSDictionary = picDict.value(forKey: "data") as! NSDictionary
      let theimg:String = dataDict.value(forKey: "url") as! String



      }





      share|improve this answer




























        -1












        -1








        -1







        You need to ask the read permission for email and profile_picture to FBSDKLogin Manager



        FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"]



        Also in GraphRequest ask for fields you require



        FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"])



        Please see below code for reference



        btn_Facebook.addTarget(self, action: #selector(handleCustomFBLogin), for: .touchUpInside)

        ///FACEBOOK LOGIN
        func handleCustomFBLogin(sender:UIButton!){
        FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self) { (result, err) in
        if(err != nil){
        print("Custom FB Login Failed")
        return
        }
        //print(result?.token.tokenString)
        self.showEmailAddress()
        }
        }

        func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!){
        if(error != nil){
        print(error)
        return
        }
        print("Successfully Logged in using facebook")
        showEmailAddress()
        }

        func showEmailAddress(){
        let accesstoken = FBSDKAccessToken.current();
        guard let accessTokenString = accesstoken?.tokenString else {return}

        FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"]).start { (connection, result, err) in
        if(err != nil){
        print("Failed to start GraphRequest", err ?? "")
        return
        }
        print(result ?? "")
        if(result != nil){
        self.sendDetailsForFacebookLogin(result: result as! NSDictionary)
        }else{
        MyCustomAlert.sharedInstance.ShowAlert(vc: self, myTitle: StringClass.sharedInstance.lcStr_loginfailedcaps, myMessage: StringClass.sharedInstance.lcStr_plsTryAgain)
        }

        }

        }

        func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!){
        print("Logged out of Facebook")
        }

        func sendDetailsForFacebookLogin(result:NSDictionary){
        //print(result)

        var theemail:String = ""
        var thefname:String = ""
        var thelname:String = ""
        var thedob:String = ""
        var thecity:String = ""
        var thereunder:String = “”

        if result["email"] != nil {
        theemail = (result.value(forKey: "email") as? String)!
        }
        if result["first_name"] != nil {
        thefname = (result.value(forKey: "first_name") as? String)!
        }
        if result["last_name"] != nil {
        thelname = (result.value(forKey: "last_name") as? String)!
        }
        if result["birthday"] != nil {
        thedob = (result.value(forKey: "birthday") as? String)!
        }
        if result["city"] != nil {
        thecity = (result.value(forKey: "city") as? String)!
        }
        if result[“gender”] != nil {
        thegender = (result.value(forKey: “gender”) as? String)!
        }

        let picDict:NSDictionary = result.value(forKey: "picture") as! NSDictionary
        let dataDict:NSDictionary = picDict.value(forKey: "data") as! NSDictionary
        let theimg:String = dataDict.value(forKey: "url") as! String



        }





        share|improve this answer















        You need to ask the read permission for email and profile_picture to FBSDKLogin Manager



        FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"]



        Also in GraphRequest ask for fields you require



        FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"])



        Please see below code for reference



        btn_Facebook.addTarget(self, action: #selector(handleCustomFBLogin), for: .touchUpInside)

        ///FACEBOOK LOGIN
        func handleCustomFBLogin(sender:UIButton!){
        FBSDKLoginManager().logIn(withReadPermissions: ["email", "public_profile"], from: self) { (result, err) in
        if(err != nil){
        print("Custom FB Login Failed")
        return
        }
        //print(result?.token.tokenString)
        self.showEmailAddress()
        }
        }

        func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!){
        if(error != nil){
        print(error)
        return
        }
        print("Successfully Logged in using facebook")
        showEmailAddress()
        }

        func showEmailAddress(){
        let accesstoken = FBSDKAccessToken.current();
        guard let accessTokenString = accesstoken?.tokenString else {return}

        FBSDKGraphRequest(graphPath: "/me", parameters: ["fields" : "id, name, first_name, last_name, gender, email, birthday, picture"]).start { (connection, result, err) in
        if(err != nil){
        print("Failed to start GraphRequest", err ?? "")
        return
        }
        print(result ?? "")
        if(result != nil){
        self.sendDetailsForFacebookLogin(result: result as! NSDictionary)
        }else{
        MyCustomAlert.sharedInstance.ShowAlert(vc: self, myTitle: StringClass.sharedInstance.lcStr_loginfailedcaps, myMessage: StringClass.sharedInstance.lcStr_plsTryAgain)
        }

        }

        }

        func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!){
        print("Logged out of Facebook")
        }

        func sendDetailsForFacebookLogin(result:NSDictionary){
        //print(result)

        var theemail:String = ""
        var thefname:String = ""
        var thelname:String = ""
        var thedob:String = ""
        var thecity:String = ""
        var thereunder:String = “”

        if result["email"] != nil {
        theemail = (result.value(forKey: "email") as? String)!
        }
        if result["first_name"] != nil {
        thefname = (result.value(forKey: "first_name") as? String)!
        }
        if result["last_name"] != nil {
        thelname = (result.value(forKey: "last_name") as? String)!
        }
        if result["birthday"] != nil {
        thedob = (result.value(forKey: "birthday") as? String)!
        }
        if result["city"] != nil {
        thecity = (result.value(forKey: "city") as? String)!
        }
        if result[“gender”] != nil {
        thegender = (result.value(forKey: “gender”) as? String)!
        }

        let picDict:NSDictionary = result.value(forKey: "picture") as! NSDictionary
        let dataDict:NSDictionary = picDict.value(forKey: "data") as! NSDictionary
        let theimg:String = dataDict.value(forKey: "url") as! String



        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 27 '18 at 4:48

























        answered Nov 17 '18 at 9:23









        Yogesh TandelYogesh Tandel

        7771912




        7771912
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53342825%2fhow-can-i-get-my-facebook-friends-profile-picture-name-and-gender%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine