Javascript 如何获得facebook用户';您的家乡和所在地在哪里?
我正在使用以下代码:Javascript 如何获得facebook用户';您的家乡和所在地在哪里?,javascript,facebook,sdk,Javascript,Facebook,Sdk,我正在使用以下代码: function testAPI() { console.log("Welcome! Fetching your information..."); FB.api('/me', function(response) { var name=response.first_name; var last-name=response.last_name; var birthday=response.birthday; var activities=response.a
function testAPI() {
console.log("Welcome! Fetching your information...");
FB.api('/me', function(response) {
var name=response.first_name;
var last-name=response.last_name;
var birthday=response.birthday;
var activities=response.activities;
var email=response.email;
var gender=response.gender;
});
我尝试通过以下方式获取用户的家乡和位置:
var hometown=response.hometown.name;
var location=response.location.name;
它只对我的个人Facebook帐户有效,对其他所有帐户无效。
有人能帮我吗?您需要通过字段扩展请求适当的字段:
FB.api('/me?fields=id,first_name,last_name,gender,activities,location,hometown,email,birthday', function(response) {
...
}
要获取要显示的所有信息,您还需要以下权限:
用户活动
user\u生日