无法使用facebook api获取current_location

时间:2014-04-02 21:15:18

标签: php facebook facebook-graph-api facebook-fql facebook-php-sdk

我有Facebook Api(PHP)的问题。 为什么无法获得授权用户的current_location(我需要纬度经度)? 有人可以帮助我理解这个权限问题吗?

$q = $my->query("SELECT id_facebook FROM Utenti");
while ($obj=$q->fetch_object())
{
    $query = 'SELECT current_location FROM user WHERE uid = '.$obj->id_facebook;
    $response = $facebook->api(array('method' => 'fql.query', 'query' => $query));
    echo "<pre>\n";
    var_dump($facebook->api("/".$obj->id_facebook."/permissions"));
    var_dump($facebook->api("/".$obj->id_facebook."?fields=location"));
    var_dump($response);
    echo "</pre><br>\n";
}

权限是:

array(2) {
    ["data"]=>
        array(1) {
            [0]=>
                array(16) {
                    ["installed"]=> int(1)
                    ["basic_info"]=>int(1)
                    ["public_profile"]=>int(1)
                    ["create_note"]=>int(1)
                    ["photo_upload"]=>int(1)
                    ["publish_actions"]=>int(1)
                    ["publish_checkins"]=>int(1)
                    ["publish_stream"]=>int(1)
                    ["status_update"]=>int(1)
                    ["share_item"]=>int(1)
                    ["video_upload"]=>int(1)
                    ["user_birthday"]=>int(1)
                    ["user_hometown"]=>int(1)
                    ["user_location"]=>int(1)
                    ["user_friends"]=>int(1)
                    ["bookmarked"]=>int(1)
                }
        }
}

$ respone示例:

array(1) {
    [0]=>
        array(1) {
            ["current_location"]=>NULL
       }
}

1 个答案:

答案 0 :(得分:0)

答案很简单:并非每个用户都在其个人资料中输入了当前城市。您确定相应的用户已设置此项吗?

否则你的代码对我来说很好。