目前在Facebook上从给定用户访问该国家有一些问题 . 我已经请求了user_location权限,我的图API调用也请求位置但是我只返回了城市和该位置的ID - 从来不是一个真实的国家 .
我的要求等如下 . 我正在使用标准的PHP SDK文档
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me?fields=birthday,name,statuses,photos,location' );
$response = $request->execute();
// get response
$response = $response->getGraphObject();
$data_we_need = array();
$data_we_need['name'] = $response->getProperty('name');
$data_we_need['birthday'] = $response->getProperty('birthday');
$data_we_need['location'] = $response->getProperty('location');
$statuses = $response->getProperty('statuses');
$data_we_need['statuses'] = $statuses->asArray();
$photos = $response->getProperty('photos');
$data_we_need['photos'] = $photos->asArray();
我的结果如下:
[name] => xxxxxx
[birthday] => 05/14/1990
[location] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Facebook\GraphObject
[backingData:protected] => Array
(
[id] => 112087812151796
[name] => Gloucester, Gloucestershire
)
)
我需要能够从提供的位置数据中获取国家/地区 .
任何帮助都将受到大力赞赏 .
1 回答
据我所知,位置和家乡字段是用户输入(社区页面),因此使用facebook API无法获得稳定的结果 . 您可能更愿意尝试使用IP自己检测国家/地区 .