Class: InstagramUpload::Request
- Inherits:
-
Object
- Object
- InstagramUpload::Request
- Defined in:
- lib/instagram_upload/request.rb
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#cookies ⇒ Object
readonly
Returns the value of attribute cookies.
Instance Method Summary collapse
-
#initialize(agent) ⇒ Request
constructor
A new instance of Request.
- #post(url, body) {|http| ... } ⇒ Object
Constructor Details
#initialize(agent) ⇒ Request
Returns a new instance of Request.
5 6 7 8 |
# File 'lib/instagram_upload/request.rb', line 5 def initialize(agent) @agent = agent @cookies = Tempfile.new('cookies') end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
3 4 5 |
# File 'lib/instagram_upload/request.rb', line 3 def agent @agent end |
#cookies ⇒ Object (readonly)
Returns the value of attribute cookies.
3 4 5 |
# File 'lib/instagram_upload/request.rb', line 3 def @cookies end |
Instance Method Details
#post(url, body) {|http| ... } ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/instagram_upload/request.rb', line 10 def post(url, body) http = Curl::Easy.new(url) http.headers['User-Agent'] = agent.user_agent http.verbose = true http.follow_location = true http. = true yield(http) if block_given? http.post(body) JSON.parse(http.body).tap { http.close } end |