0

When a user signs into my website using Facebook I can get the 'locale' from the Facebook API. How do I get the country name though? I wish to display the name of the country efficiently. Currently 'locale' gives me only the country code 'en_GB'.

I do not wish to create a switch statement converting every country code to a country name as I would like a more efficient approach. Is the country name available from the API?

StevenPHP
  • 3,547
  • 3
  • 17
  • 20
  • if you query standard_user_info https://developers.facebook.com/docs/reference/fql/standard_user_info/, i think you will be able to get the location – Akhil Sidharth Feb 18 '14 at 16:46
  • Country name you can get using the api call as me?fields=id,name,location,timezone,languages I have added some extra fields for testing. You can check here https://developers.facebook.com/tools/explorer/ Country name is returned as location – Abhik Chakraborty Feb 18 '14 at 17:09

1 Answers1

0

You can use fb PHP SDK and after proper loading using following code:

<? if( $userfb = $facebook->getUser() ) {echo $user_location['location']['name'];} ?>