Class: Weibo2Plugins::Tools::Api
- Inherits:
-
Object
- Object
- Weibo2Plugins::Tools::Api
- Defined in:
- lib/weibo2_plugins/weibo2_plugins.rb
Constant Summary collapse
- HOST =
"https://api.weibo.com/2"
Class Method Summary collapse
-
.get_friend(uid, url, access_token) ⇒ Object
Weibo2Plugins::Tools::Api.get_friend(‘1925715145’,‘/friendships/friends.json’,‘2.00hTG1GCDSHn2C64fbb3f2d30n2pHb’).
-
.post_statuses(uid, url, access_token, status) ⇒ Object
Weibo2Plugins::Tools::Api.post_statuses(‘1925715145’,‘/statuses/update.json’,‘2.00hTG1GCDSHn2C64fbb3f2d30n2pHb’,‘test’).
Class Method Details
.get_friend(uid, url, access_token) ⇒ Object
Weibo2Plugins::Tools::Api.get_friend(‘1925715145’,‘/friendships/friends.json’,‘2.00hTG1GCDSHn2C64fbb3f2d30n2pHb’)
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/weibo2_plugins/weibo2_plugins.rb', line 54 def self.get_friend(uid,url,access_token) params = {uid: uid, access_token: access_token, count: 200} atts = { headers: {"Content-Type" => "application/json","Accept"=>"application/json;charset=utf-8","User-Agent"=>"Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"}, method: :get, timeout: 3000, :cache_timeout => 0, disable_ssl_peer_verification: true, params: params } request = Typhoeus::Request.new("#{HOST}#{url}",atts) hydra = Typhoeus::Hydra.new hydra.queue(request) hydra.run result = $json.decode(request.response.body) end |
.post_statuses(uid, url, access_token, status) ⇒ Object
Weibo2Plugins::Tools::Api.post_statuses(‘1925715145’,‘/statuses/update.json’,‘2.00hTG1GCDSHn2C64fbb3f2d30n2pHb’,‘test’)
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/weibo2_plugins/weibo2_plugins.rb', line 68 def self.post_statuses(uid,url,access_token,status) params = {uid: uid, access_token: access_token, status: URI.escape(status).to_json} atts = { headers: {"Content-Type" => "application/x-www-form-urlencoded","Accept"=>"application/json;charset=utf-8","User-Agent"=>"Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"}, method: :post, timeout: 3000, cache_timeout: 0, disable_ssl_peer_verification: true, params: params } request = Typhoeus::Request.new("#{HOST}#{url}",atts) hydra = Typhoeus::Hydra.new hydra.queue(request) hydra.run result = $json.decode(request.response.body) end |