我正在创建Facebook应用程序,用户可以在朋友列表中获取所有朋友的公司名称
FB.api('/me', function(response) {
var query = FB.Data.query('select name,work,work_history,pic_square
from user where uid IN (SELECT uid2 FROM friend WHERE uid1={0})', response.id)
query.wait(function(rows){
var data = "";
for (var i = 0; i < rows.length;i++) {
data += rows[i].name + " => " +'<img src="' +rows[i].pic_square + '" alt="image" />' + "===> ";
if(rows[i].work[i]||rows[i].work_history[i]) {
data+=rows[i].work_history[0].company_name+ "<br/>";
}
data += "<br />";
}
document.getElementById('location').innerHTML = data;
});
});
}
答案 0 :(得分:1)
您应该查看https://developers.facebook.com/blog/post/561/
FB.Data.query很久以前就被弃用了。以下是如何实现相同目标的示例:http://www.fbrell.com/saved/b9b65bf81dc84b58fc1e167167b13112(请注意,它仅使用work_history
,请同时查看work
。
需要考虑的一些事项: