Sha256: 8a3ff4497cb9583362910d970ed26b7134b54158535ac760e633e20c9f6b5da9
Contents?: true
Size: 960 Bytes
Versions: 2
Compression:
Stored size: 960 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 FbGraph::Exception.new(response[:error_code], response[:error_msg]) else response end else response end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fb_graph-1.2.1 | lib/fb_graph/query.rb |
fb_graph-1.2.0 | lib/fb_graph/query.rb |