Skip to content

Instantly share code, notes, and snippets.

@brundage
Created October 4, 2012 05:38
Show Gist options
  • Save brundage/3831662 to your computer and use it in GitHub Desktop.
Save brundage/3831662 to your computer and use it in GitHub Desktop.
Facebook get mentions (tagged)
require 'koala'
me = Koala::Facebook::API.new 'AAAC...' # get this from https://developers.facebook.com/tools/explorer - get user_status,manage_pages permissions
pages = me.get_connections('me', 'accounts')
# Find your page's access token
nrb = Koala::Facebook::API.new 'AAAC...' # see acting as a page https://github.com/arsduo/koala/wiki/Acting-as-a-Page
feed = nrb.get_connection('me', 'tagged')
# Accumulate the feed
mentions = feed.select { |p| ! p["message_tags"].nil? } # Sometimes tagged posts don't have tags
puts mentions.collect { |m| m["from"]["name"] }
# Then check if it is a person
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment