Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Is there a way to get user country,state,city information from Facebook. I had a research on this but have not got anything related to this......
Posted
Updated 28-Jun-13 21:47pm
v2
Comments
DaveAuld 29-Jun-13 3:59am    
Only if the user has made this information public and the relevant fields are supported in the facebook APIs. Check the developer pages on FB to get more details on the implementation.

1 solution

try this
JavaScript
<script type="text/javascript">
                  window.fbAsyncInit = function() {
                    FB.init({
                      appId      : 'YOUR_APP_ID_HERE', // App ID
                      channelUrl : 'http://localhost.com/channel.html', // Channel File
                      status     : true, // check login status
                      cookie     : true, // enable cookies to allow the server to access the session
                      oauth      : true, // enable OAuth 2.0
                      xfbml      : true  // parse XFBML
                    });
                  };
                  (function(d){
                     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                     js = d.createElement('script'); js.id = id; js.async = true;
                     js.src = "//connect.facebook.net/en_US/all.js";
                     d.getElementsByTagName('head')[0].appendChild(js);
                   }(document));
                </script>
                 
                <h1>Registration</h1>
                 
                <div style="float: left; margin-right: 15px;">
                     
                    <div class="fb-registration">
                        data-fields='[{"name":"name"},
                                        {"name":"birthday"},
                                        {"name":"location"}, //this retrieves the location of the user
                                        {"name":"gender"},
                                        {"name":"email"},
                                        {"name":"username","description":"Username","type":"text"},
                                        {"name":"password"}]' 
                        data-redirect-uri="http://localhost.com/register.php">
                     

</div></div>
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900