FQL query info & get Facebook friends by first letter

For example, show all friends of logged in user starting with “j”. (requires valid access token – e.g., from your app or Graph API Explorer or use the legacy fql test console):

SELECT name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me() ) AND strpos(lower(name),"j")==0

To use as a GET request directly from FB:

https://api.facebook.com/method/fql.query?query=SELECT%20name%20FROM%20user%20WHERE%20uid%20IN%20(%20SELECT%20uid2%20FROM%20friend%20WHERE%20uid1=me()%20)%20AND%20strpos(lower(name),%22j%22)%20==0&access_token=VALID_ACCESS_TOKEN

You can call this directly as above if you have an access token, but more likely you would use the FB API, like the JS, or PHP, SDK.

FQL links:
FB FQL Reference
FB friend API reference
slideshare fql-overview

Click here to see a simple JavaScript SDK example of fql.query

FB.api(
  {
    method: 'fql.query',
    query: 'SELECT name FROM user WHERE uid=5526183'
  },
  function(response) {
    alert('Name is ' + response[0].name);
  }
);

Leave a Reply