Skip to content

Instantly share code, notes, and snippets.

@sunny0425
Created November 14, 2012 08:28
Show Gist options
  • Save sunny0425/4070990 to your computer and use it in GitHub Desktop.
Save sunny0425/4070990 to your computer and use it in GitHub Desktop.
use fql and fb_graph to search friends by user name for facebook
# reference:
# - https://github.com/nov/fb_graph
# - https://gist.github.com/752914
# - http://developers.facebook.com/docs/reference/fql/
# - http://stackoverflow.com/questions/7352296/facebook-fql-search-page-with-strpos-doesnt-work
require 'fb_graph'
user_access_token = 'USER_ACCESS_TOKEN'
fb_user = FbGraph::User.me(user_access_token)
FbGraph::Query.new("SELECT uid, name, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND strpos(lower(name),'hen') > 0").fetch(user_access_token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment