尝试获取用户个人资料数据但我只获得用户ID,链接,名称,first_name,last_name,电子邮件和性别。剩余值未定义。但根据facebook javascript sdk我已经通过字段所以它应该必须提供给我所有我需要的字段。
FB.api('/me', {fields: 'id,link,name,first_name,last_name,email,birthday,education,gender,hometown,location,religion,relationship_status,work'},function(response) {
console.log(response);
var str="<b>Name</b> : "+response.name+"<br>";
str="<b>First Name</b> : "+response.first_name+"<br>";
str="<b>Last Name</b> : "+response.last_name+"<br>";
str +="<b>Link: </b>"+response.link+"<br>";
str +="<b>Username:</b> "+response.location.name+"<br>";
str +="<b>id: </b>"+response.id+"<br>";
str +="<b>Email:</b> "+response.email+"<br>";
str +="<input type='button' value='Get Photo' onclick='getPhoto();'/>";
str +="<input type='button' value='Logout' onclick='Logout();'/>";
document.getElementById("status").innerHTML=str;
});
控制台结果:
email
"hassanali5420@yahoo.com"
first_name
"Hassan"
gender
"male"
id
"1517510821901697"
last_name
"ALi"
link
"https://www.facebook.com/app_scoped_user_id/1517510821901697/"
name
"Hassan ALi"