Facebook Graph API - how to get user country?

后端 未结 10 1650
心在旅途
心在旅途 2020-11-30 02:56

I\'m developing a Facebook application using their Graph API. I have previously developed an app using the deprecated REST API.

I\'ve come across a problem in that

10条回答
  •  时光说笑
    2020-11-30 03:08

    Use the php sdk:

    require 'facebook.php';

    $facebook = new Facebook(array( 'appId' => 'APPID', 'secret' => 'APPSECRET',
    'cookie' => true, ));

    Then ask for a signed request:

      $signed_request = $facebook->getSignedRequest();
      $country = $signed_request["user"]["country"];
    

    Now $country has a string such as "us" for United States and "uk" for United Kingdom etc.

提交回复
热议问题