通过facebook图形API检索Facebook用户的邮政编码 [英] Retrieve zip code of a facebook user by facebook graph API
问题描述
我正在尝试使用Facebook图形API来检索用户的邮政编码。我正在使用跟踪代码。代码是php。
I am trying to retrieve Zip code of a user using facebook graph API. I am using follow code for that. Code is in php.
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
));
$user = $facebook->getUser();
//$login_url = $facebook->getLoginUrl(array( 'scope' => 'email'));
$login_url = $facebook->getLoginUrl(
array(
'scope' => 'email,publish_stream,user_birthday,user_location,user_work_history,user_about_me,user_hometown'
)
);
//get user basic description
//$userInfo = $facebook->api("/$user");
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
这里我得到$ user_profile数组,它有其他所有信息码。但是我给了这个许可。有没有办法从Facebook获取邮政编码。
Here I am getting the $user_profile array, It has all information other that zip code. But I gave permission for that. Is there any way to get zip code from facebook.
推荐答案
如果您查看 /我
致电 https://developers.facebook.com / docs / reference / api / user / 你会注意到没有提到用户的邮政编码或邮政编码。
If you check the documentation for the /me
call at https://developers.facebook.com/docs/reference/api/user/ you'll note that there is no reference to the user's zip or postal code.
我建议你请使用 user_location
权限,然后调用 / me?fields = location
并尝试从其中包含的信息 - 此回答 https://stackoverflow.com/a/7129344/2091159 - 有一些有关这方面的信息。
I'd recommend you use ask for the user_location
permission and then call /me?fields=location
and try to derive the zip code from the information contained therein - this answer https://stackoverflow.com/a/7129344/2091159 - has some information about doing so.
这篇关于通过facebook图形API检索Facebook用户的邮政编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!