module Graham::API

Public Instance Methods

add_comment(media_id, comment_text) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 102
def add_comment(media_id, comment_text)
  url = "/v1/media/#{media_id}/comments"
  encoded_text = URI.encode(comment_text)
  post(url, {text: encoded_text}) do |res, body|
    yield(res, body) if block_given?
  end
end
add_like(media_id) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 81
def add_like(media_id)
  url = "/v1/media/#{media_id}/likes"
  post(url) do |res, body|
    yield(res, body) if block_given?
  end
end
comments(media_id) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 95
def comments(media_id)
  url = "/v1/media/#{media_id}/comments"
  get(url) do |res, body|
    yield(res, body) if block_given?
  end
end
delete_comment(media_id, comment_id) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 110
def delete_comment(media_id, comment_id)
  url = "/v1/media/#{media_id}/comments/#{comment_id}"
  delete(url) do |res, body|
    yield(res, body) if block_given?
  end
end
delete_like(media_id, like_id) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 88
def delete_like(media_id, like_id)
  url = "/v1/media/#{media_id}/likes"
  delete(url) do |res, body|
    yield(res, body) if block_given?
  end
end
get_access_token(code) { |token| ... } click to toggle source
# File lib/graham/api.rb, line 8
def get_access_token(code)
  url = '/oauth/access_token'
  res = post(url, {
    client_id: config.client_id,
    client_secret: config.client_secret,
    grant_type: 'authorization_code',
    redirect_uri: config.redirect_uri,
    code: code
    })

  token = nil
  if res.success?
    body = JSON.parse res.body
    token = body["access_token"]
    config.access_token = token
  end
  yield(token) if block_given?
  token
end
likes(media_id) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 74
def likes(media_id)
  url = "/v1/media/#{media_id}/likes"
  get(url) do |res, body|
    yield(res, body) if block_given?
  end
end
locations_search_by_fb_place_id(location) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 117
def locations_search_by_fb_place_id(location)
  url = "/v1/locations/search"
  get(url, {facebook_places_id: location}) do |res, body|
    yield(res, body) if block_given?
  end
end
locations_search_by_lat_lng(lat, lng) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 124
def locations_search_by_lat_lng(lat, lng)
  url = "/v1/locations/search"
  get(url, {lat: lat, lng: lng}) do |res, body|
    yield(res, body) if block_given?
  end
end
tags_info(tagname) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 49
def tags_info(tagname)
  url                         = "/v1/tags/#{tagname}"
  get(url) do |res, body|
    yield(res, body) if block_given?
  end      
end
tags_recent(tagname, count = -1, min_tag_id = -1, max_tag_id = -1) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 56
def tags_recent(tagname, count = -1, min_tag_id = -1, max_tag_id = -1)
  url                         = "/v1/tags/#{tagname}/media/recent"
  options                     = {}
  options["count"]            = count if count >= 0
  options["min_tag_id"]       = min_tag_id if min_tag_id >= 0
  options["max_tag_id"]       = max_tag_id if max_tag_id >= 0
  get(url, options) do |res, body|
    yield(res, body) if block_given?
  end
end
users(userid) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 28
def users(userid)
  url = "/v1/users/#{userid}"
  get(url) do |res, body|
    yield(res, body) if block_given?
  end
end
users_recent(userid) { |res, body| ... } click to toggle source
# File lib/graham/api.rb, line 35
def users_recent(userid)
  url = "/v1/users/#{userid}/media/recent"
  get(url) do |res, body|
    yield(res, body) if block_given?
  end
end