Class: InstagramUpload::Client
- Inherits:
-
Object
- Object
- InstagramUpload::Client
- Defined in:
- lib/instagram_upload/client.rb
Constant Summary collapse
- API_URL =
'https://instagram.com/api/v1/'.freeze
- LOGIN =
API_URL + 'accounts/login/'
- UPLOAD_PHOTO =
API_URL + 'media/upload/'
- CONFIGURE_PHOTO =
API_URL + 'media/configure/'
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #configure_photo(media_id, caption) ⇒ Object
-
#initialize(username, password) ⇒ Client
constructor
A new instance of Client.
- #upload_photo(image, caption) ⇒ Object
Constructor Details
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
9 10 11 |
# File 'lib/instagram_upload/client.rb', line 9 def agent @agent end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
9 10 11 |
# File 'lib/instagram_upload/client.rb', line 9 def password @password end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
9 10 11 |
# File 'lib/instagram_upload/client.rb', line 9 def request @request end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
9 10 11 |
# File 'lib/instagram_upload/client.rb', line 9 def username @username end |
Instance Method Details
#configure_photo(media_id, caption) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/instagram_upload/client.rb', line 34 def configure_photo(media_id, ) body = agent.body( device_timestamp: , media_id: media_id, caption: , source_type: 5, filter_type: 0, extra: {} ) request.post(CONFIGURE_PHOTO, body) do |http| http. = request..path end end |
#upload_photo(image, caption) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/instagram_upload/client.rb', line 20 def upload_photo(image, ) data = [ Curl::PostField.file('photo', image), Curl::PostField.content('device_timestamp', ) ] result = request.post(UPLOAD_PHOTO, data) do |http| http.multipart_form_post = true http. = request..path end configure_photo(result['media_id'], ) end |