Module: Fql
- Defined in:
- lib/fql.rb,
lib/fql/query.rb,
lib/fql/version.rb
Defined Under Namespace
Constant Summary collapse
- BASE_URL =
'https://graph.facebook.com/fql?q='
- VERSION =
"0.3.1"
Class Method Summary collapse
-
.execute(query, options = {}) ⇒ Object
Sends an FQL query to Facebook.
-
.make_url(fql_query, options = {}) ⇒ Object
Constructs the Facebook url which will return the results from the FQL query.
Class Method Details
.execute(query, options = {}) ⇒ Object
Sends an FQL query to Facebook.
Exampe: a single query without access_token
Fql.execute('SELECT first_name, last_name FROM user WHERE uid = 4')
Exampe: a multi query with an access_token
= { :access_token => "fb_access_token", :appsecret_proof => "appsecret_proof" }
Fql.execute({
"query1" => "SELECT uid, rsvp_status FROM event_member WHERE eid = 12345678",
"query2" => "SELECT name FROM profile WHERE id IN (SELECT uid FROM #query1)"
}, )
26 27 28 29 30 31 |
# File 'lib/fql.rb', line 26 def execute(query, = {}) fql_query = Fql::Query.new query url = make_url(fql_query, ) response = make_request url self.decode_response response end |
.make_url(fql_query, options = {}) ⇒ Object
Constructs the Facebook url which will return the results from the FQL query. The FQL query and optional access_token are passed as GET parameters.
37 38 39 40 41 42 43 |
# File 'lib/fql.rb', line 37 def make_url(fql_query, = {}) url = self::BASE_URL + URI.encode(fql_query.compose) url += URI.encode("&access_token=#{[:access_token]}") if && [:access_token] url += URI.encode("&appsecret_proof=#{[:appsecret_proof]}") if && [:appsecret_proof] URI.parse url end |