Running an FQL query using Facebook's Javascript SDK

后端 未结 2 1596
臣服心动
臣服心动 2021-01-28 16:25

This is my query:

select uid, name, is_app_user from user where uid in (select uid2 from friend where uid1=me()) and is_app_user=1

and I need t

相关标签:
2条回答
  • 2021-01-28 16:34

    Execute query via FB.api-

    FB.api("/fql?q="+encodeURIComponent('{your-query}'), function(response) {
      if (!response || response.error) {
         console.log('Error occurred: '+response.error.message);
      } else {
         console.log(response);
      }
    });
    
    0 讨论(0)
  • 2021-01-28 16:45

    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=
    

    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 code would look like this for example:

    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!

    0 讨论(0)
提交回复
热议问题