class Send

Public Class Methods

new(image_url, caption, config, request) click to toggle source
# File lib/instagramp.rb, line 9
def initialize(image_url, caption, config, request)
  @image_url = image_url
  @caption  = caption
  @config = config
  @request = request
end
post(image_url, caption, config, request) click to toggle source
# File lib/instagramp.rb, line 32
def self.post(image_url, caption, config, request)
  new(image_url, caption, config, request).post
end

Public Instance Methods

generate_token() click to toggle source
# File lib/instagramp.rb, line 16
def generate_token
  Instagram::Post::Token.get_access_token(@config, request)[:token]
end
post() click to toggle source
# File lib/instagramp.rb, line 20
def post
  token = generate_token
  ids = Instagram::Post::Account.new(@config, token).generate_id(@image_url, @caption)
  ids.each do |id|
    HTTParty.post("https://graph.facebook.com/id/media_publish?access_token=#{token}",
                  :body => {
                    creation_id: id
                  }
                 )
  end
end