How to get person's address using Facebook Javascript SDK?
I am able to get the name and email like this:
FB.api('/me', function(response)
{
alert ("Name when logged in:" + response.name);
alert ("Name when logged in:" + response.email);
});
But in the FB documentation, I don't see how to ge开发者_StackOverflowt address. Also, how can I download their photo?
As I understand it, their photo can be retrieved from this url: http://graph.facebook.com/FACEBOOK_USER_ID/picture
But how do I get their facebook user id?
Also, to get the address, I am trying something like this:
alert ("Location:" + response.location);
alert ("Location:" + response.location.city);
alert ("Location:" + response.location.country);
alert ("Location:" + response.location.zip);
alert ("Location:" + response.location.state);
But that doesn't work. Anyone know how to get at these fields? Thanks!
FB.api('/me')
Will give you the user's id without requiring any special permissions.
You can't get address as such, you can get location
using the user_location
permission. Then you'll be able to get it via the same /me
method.
Facebook Developers doc:
https://developers.facebook.com/docs/reference/api/user/
Actually all that info is here: http://developers.facebook.com/docs/reference/api/user/
But it took a long time to find that page!
精彩评论