Sha256: 4beb5ddefd5565cda76c12c7fee71670c4284b3ccd6c77a2aeb49e1678e709cf
Contents?: true
Size: 951 Bytes
Versions: 1
Compression:
Stored size: 951 Bytes
Contents
module FbGraph class Query < Node attr_accessor :access_token, :query def initialize(query, access_token = nil) @query = query @access_token = access_token end def fetch(access_token = nil) self.access_token ||= access_token handle_response do RestClient.get build_endpoint end end private ENDPOINT = 'https://api.facebook.com/method/fql.query' def build_endpoint params = stringfy_access_token( :query => self.query, :access_token => self.access_token, :format => :json ) ENDPOINT + "?#{params.to_query}" end def handle_response response = super do yield end case response when Hash if response[:error_code] raise Exception.new(response[:error_code], response[:error_msg]) else response end else response end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fb_graph-1.2.2 | lib/fb_graph/query.rb |