使用Facebook的Javascript SDK运行FQL查询 [英] Running an FQL query using Facebook's Javascript SDK
问题描述
这是我的查询:
select uid, name, is_app_user from user where uid in (select uid2 from friend where uid1=me()) and is_app_user=1
我需要使用Javascript SDK运行它。我该怎么做呢?我不确定语法和格式。当我在Open Graph Explorer(FBL部分)中运行它时,上面的FQL查询有效,但我无法让它在Graph API部分中运行。
and I need to run it using the Javascript SDK. How do I do this? I'm not sure about the syntax and formatting. The above FQL query works when I run it in the Open Graph Explorer (FBL section) but I can't manage to get it to work in the Graph API section.
谢谢
推荐答案
您可以通过JS SDK的FB.api()方法运行它( https://developers.facebook.com/docs/javascript/reference/FB.api )
You can run this via the FB.api() method of the JS SDK (https://developers.facebook.com/docs/javascript/reference/FB.api) by using the
/fql?q=
端点,如果你像这样对你的查询进行URL编码
endpoint if you URL encode your query like this
/fql?q=select%20uid%2C%20name%2C%20is_app_user%20from%20user%20where%20uid%20in%20(select%20uid2%20from%20friend%20where%20uid1%3Dme())%20and%20is_app_user%3D1&access_token={YOUR_USER_ACCESS_TOKEN}
JS代码如下所示:
FB.api('/fql?q=select%20uid%2C%20name%2C%20is_app_user%20from%20user%20where%20uid%20in%20(select%20uid2%20from%20friend%20where%20uid1%3Dme())%20and%20is_app_user%3D1&access_token={YOUR_USER_ACCESS_TOKEN}', function(response) {
console.log(response);
});
别忘了添加您的访问令牌!
Don't forget to add your Access Token!
这篇关于使用Facebook的Javascript SDK运行FQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!