开发者

PHP: Facebook JSON objects

I'm trying to get the user location from Facebook.

In the Graph API › User page, says:

location : A JSON object containing name and id

I need the location name, and I cannot get it. So far I've done:

$loc = $facebook->api('/me', array('fields' => 'location'));

But I don't get it and 开发者_JS百科don't know what else to do ..

Thanks a ton!


You'll need to request the "user_location" privilege.

If you're using the Login Button, add it to the perms parameter.

<fb:login-button perms="user_location"></fb:login-button>

If you're using the Javascript API, add it to the options parameter:

FB.login(function(response) {
    if (response.session) {
        // do stuff
    }
}, { perms:"user_location" });

You may also want to try this to see what data is available.

$response = $facebook->api('/me');
var_dump($response);


Make sure you have right privileges, If not request them first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜