Skip to content
nov edited this page May 8, 2013 · 8 revisions

FQL

Query given permissions

require 'fb_graph'

permission_candidates = [
  :email,
  :sms,
  :read_stream,
  :publish_stream
]

permissions = FbGraph::Query.new(
  "SELECT #{permission_candidates.join(',')} FROM permissions WHERE uid = me()"
).fetch(:access_token => ACCESS_TOKEN)

permission_candidates.each do |candidate|
  answer = case permissions.first[candidate]
  when 0
    "YES"
  when 1
    "NO"
  end
  puts "Has #{candidate} permission? => #{answer}"
end

Multi Query

FbGraph::Query.new({
  :query1 => 'SELECT uid FROM user WHERE uid = me()',
  :query2 => 'SELECT name FROM user WHERE uid = me()',
}).fetch(:access_token => ACCESS_TOKEN)
# => {"query1" => [{"uid" => 579612276}], "query2" => [{"name" => "Nov Matake"}]}
Clone this wiki locally