0

I am using facebook api to login through facebook in my web application but email is null. I am using code mentioned in below article

http://www.aspsnippets.com/Articles/Autheticate-Users-login-account-using-FaceBook-API-in-ASPNet-Website.aspx

Now I have created app in facebook and here is screen shot enter image description here

Code I am using 1st to connect to facebook

//FaceBookConnect.Authorize("user_photos,email", Request.Url.AbsoluteUri.Split('?')[0]);
            FaceBookConnect.Authorize("email,public_profile,user_friends", Request.Url.AbsoluteUri.Split('?')[0]);

then when returned back

string code = Request.QueryString["code"];
                if (!string.IsNullOrEmpty(code))
                {

                        string data = FaceBookConnect.Fetch(code, "me");
                        FaceBookUser faceBookUser = new JavaScriptSerializer().Deserialize<FaceBookUser>(data);
                        faceBookUser.PictureUrl = string.Format("https://graph.facebook.com/{0}/picture", faceBookUser.Id);

                        password = faceBookUser.Id;
                        username = faceBookUser.Name;
                        string name = faceBookUser.UserName;
                        input_username_email = faceBookUser.Email;
                        Image = faceBookUser.PictureUrl;
                        MainLogin(Tusername: username, password: password, IsFB: true, Email: input_username_email);

                }

but username and email is null always.

How can i get email ??

Mahajan344
  • 2,492
  • 6
  • 39
  • 90
  • The `username` field has been removed with API v2.0, and the duplicate explains that you need to ask for the fields you want since v2.4 (How to specify fields with your SDK, should be in its documentation.) – CBroe Oct 02 '16 at 09:34
  • but If I try 'FaceBookConnect.Fetch(code, "me?fields=email,first_name,last_name"); ' .. I am getting bad request error – Mahajan344 Oct 02 '16 at 09:41
  • Well then that is probably not the correct way to specify fields with the SDK you are using. So _have_ you checked its docs ...? – CBroe Oct 02 '16 at 10:06
  • thats what I am trying to search to get email id througfh facebook c# api.. as per new new api version :( – Mahajan344 Oct 02 '16 at 10:12
  • 1
    I suggest you consult some resources that aren't as old as the one you've taken your code from (2012 is an _eternity_ ago in IT terms.) – CBroe Oct 02 '16 at 11:04

0 Answers0