-
-
Save eLafo/999092 to your computer and use it in GitHub Desktop.
Euruko demo code (Koala & Facebook)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demo from Euruko lightning talk 2011 | |
# links: | |
# * http://github.com/arsduo/koala (code/wiki documentation) | |
# * http://oauth.twoalex.com (easy access tokens) | |
# * http://developers.facebook.com/docs/coreconcepts/ (FB docs) | |
# the person I hang out with most | |
people = g.fql_query("select tagged_uids from checkin where author_uid = me()") | |
bestfriend = people.collect {|c| c["tagged_uids"]}.flatten.group_by {|u| u}.values.max_by(&:length).first | |
Koala::Facebook::GraphAPI.batch do | |
g.get_object(bestfriend, {}, :batch_args => {:name => "friend"}) | |
g.put_wall_post("Calculated all my check-ins for this #euruko demo. Turns out I spend most of my time with {result=friend:$.name}!") | |
end | |
# the people who've commented on my posts recently | |
# you can use the limit argument to expand/contract the # of results | |
commenters = g.rest_call("fql.multiquery", :queries => { | |
:query1 => "select post_id from stream where source_id = me()", | |
:query2 => "select fromid from comment where post_id in (select post_id from #query1)", | |
:query3 => "select uid, name from user where uid in (select fromid from #query2)" | |
}.to_json) | |
commenters.last["fql_result_set"].collect {|u| u["name"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment