Click here to Skip to main content
13,095,004 members (79,404 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I want functionality login with facebook. I have completed all necessary steps for this but now problem is i only able to access name of logged user via facebook, now i want to retrive all information mentioned below in my code.

<head runat="server">
    <title>Login With Facebook</title>
    <script type="text/javascript" src=""></script>
        // Load the SDK Asynchronously
        (function (d) {
            var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
            if (d.getElementById(id)) { return; }
            js = d.createElement('script'); = id; js.async = true;
            js.src = "//";
            ref.parentNode.insertBefore(js, ref);
        } (document));
        // Init the SDK upon load
        window.fbAsyncInit = function () {
                appId: 'xxxxxxxxxxxxxxxxxx', // Your App ID
                channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            // listen for and handle auth.statusChange events
            FB.Event.subscribe('auth.statusChange', function (response) {
                if (response.authResponse) {
                    // user has auth'd your app and is logged into Facebook
                    var uid = "" + response.authResponse.userID + "/picture";
                    FB.api('/me', function (me) {
                        document.getElementById('auth_displayname').innerHTML =;
                        document.getElementById('Email').innerHTML =;
                        document.getElementById('profileImg').src = uid;
                        document.getElementById('DOB_User').innerHTML = me.birthday;
                        document.getElementById('City').innerHTML = response.authResponse.userID;
                        document.getElementById('Gender_User').innerHTML = me.gender;
                    document.getElementById('auth-loggedout').style.display = 'none';
                    document.getElementById('auth-loggedin').style.display = 'block';
                } else {
                    // user has not auth'd your app, or is not logged into Facebook
                    document.getElementById('auth-loggedout').style.display = 'block';
                    document.getElementById('auth-loggedin').style.display = 'none';
            $("#auth-logoutlink").click(function () { FB.logout(function () { window.location.reload(); }); });
        Facebook Login Authentication Example</h1>
    <form id="form1" runat="server">
        <div id="auth-status">
            <div id="auth-loggedout">
                <div class="fb-login-button" autologoutlink="false" scope="email,user_birthday">
                    Login with Facebook</div>
            <div id="auth-loggedin" style="display: none">
                Name: <span id="auth_displayname" runat="server"></span>(<a href="#" id="auth-logoutlink">logout</a>)<br />
                Email: <span id="Email" runat="server"></span>
                <br />
                Profile Image:
                <img id="profileImg"  alt="" runat="server"/><br />
                D.O.B. :
                <asp:Literal ID="DOB_User" runat="server"></asp:Literal><br />
                City :
                <asp:Literal ID="City" runat="server"></asp:Literal>
                Gender :
                <asp:Literal ID="Gender_User" runat="server"></asp:Literal>
            <asp:ImageButton ID="ImageButton1" ImageUrl="~/Admin/images/face1.gif" runat="server"
                OnClientClick="login()" />        </div>

This code work fine but provide only the name of logged in user not other informations like email, dob etc. Sowhat can i do. Please help me with proper code.
Posted 29-Apr-13 19:31pm
Updated 29-Apr-13 23:05pm
Tadit Dash 4-Jun-14 10:13am
Does your app have all permissions to access the User Details?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

sonusharma65 30-Apr-13 7:06am
I have successfully logged in using "Login with facebook" but there is one issue in my mind that is :
If the user is not registered with my web application and have an account on facebook, when he tries to login with facebook at my website without having any account on it then what will happen or how should i manage it.
if user is registered at both(in my web site and on facebook) then when he tries to login with facebook i want to create a session for that user to access another pages, How can i code for this...
Please help me
Sunil sharma
kkakadiya 30-Apr-13 7:19am
Hi sonu,

till i have faced this type of situations, if user have not registered in your site then we are providing facility to login with facebook account.right nw u are doing that by signing with fb acc successfully.right.
if user have account in both sites then still user can access other pages.
kkakadiya 30-Apr-13 7:24am
i have just checked it and it is working on fb login i can access/redirect to other pages..
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can retrive all information using JSon object like:-

ComputerBeacon.Facebook.Models.User fbUser = new ComputerBeacon.Facebook.Models.User("me", objWebContext.Session.AccessToken);
JsonArray JA = Api.Fql("SELECT uid, name, pic_square, profile_url, email FROM user WHERE uid = UserId, objWebContext.Session.AccessToken);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 4 Jun 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100