这可能听起来有点滑稽,但我不知道如何使用javascript获取从Facebook FQL查询中获取的数据。我正在寻找网络,只有关于如何运行查询但现在如何获取数据的教程。
所以这是我的代码:
if (response.session) {
FB.api({
method: "fql.query",
query: "SELECT name,email FROM user WHERE uid = " + response.session.uid
});
customar_formcode="'.$formcode.'";
customar_formcode=customar_formcode.replace("{email}", USER EMAIL FROM THE FQL);
customar_formcode=customar_formcode.replace("{name}", USER NAME FROM THE FQL);
document.getElementById('form').submit();
那么如何将用户的姓名和电子邮件放在“来自FQL的用户电子邮件”和“来自FQL的用户名”中。
感谢。
答案 0 :(得分:1)
您必须定义回调函数:
FB.api({
method: "fql.query",
query: "SELECT name,email FROM user WHERE uid = " + response.session.uid
},
function(response) {
//Here you have acces to response from FB.
//Use console.log(response) (in firebug in FF) to watch what is in it:)
}
);