Sha256: ab2c2d16b92e22cb7a34765fef38e5c8c5334130be2e18cea367be1aa05d1415
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Invity module Facebook class API GraphUrl = 'https://graph.facebook.com' attr_reader :access_token attr_accessor :fields def initialize(access_token = nil) @access_token = access_token end def friends self.fields = 'fields=id,name' @friends ||= response end def friends_with_pics self.fields = 'fields=id,name,picture.type(small)' @friends_with_pics ||= response end def friend_ids @friend_ids ||= friends.map { |f| f['id'] } end private #----------------------------------------------------- def api @api ||= Faraday.new(:url => GraphUrl) do |f| f.request :url_encoded f.response :logger f.adapter Faraday.default_adapter end end def prepare_url "/me/friends?#{fields}&access_token=#{access_token}" end def response raise request.headers['www-authenticate'] if request.status != 200 JSON.parse( (request).body )['data'] end def request @request ||= api.get prepare_url end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
invity-0.0.1 | lib/invity/facebook.rb |