weibo2_plugins 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module Weibo2Plugins
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -3,8 +3,9 @@
3
3
  require 'typhoeus'
4
4
 
5
5
  module Weibo2Plugins
6
- # Weibo2Plugins::Base.get_call_back_url('2154274819','74e4428b7ed95bf47317ee31075ea802',"http://www.tianji.com/api/users/weibo_callback")
7
- class Base
6
+
7
+ class Base
8
+ # Weibo2Plugins::Base.get_call_back_url('2154274819','74e4428b7ed95bf47317ee31075ea802',"http://www.tianji.com/api/users/weibo_callback")
8
9
  def self.get_call_back_url weibo_key,weibo_secret,call_back_url
9
10
  Weibo2::Config.api_key = weibo_key
10
11
  Weibo2::Config.api_secret = weibo_secret
@@ -12,12 +13,42 @@ module Weibo2Plugins
12
13
  client = Weibo2::Client.new
13
14
  client.auth_code.authorize_url(:response_type => "token")
14
15
  end
15
-
16
16
  end
17
- # Weibo2Plugins::Tools::Base.get_friend('1925715145','/friendships/friends.json','2.00hTG1GCDSHn2C64fbb3f2d30n2pHb')
17
+
18
18
  module Tools
19
19
  class Base
20
20
  HOST = "https://api.weibo.com/2"
21
+
22
+ def self.get_date(url,access_token,params)
23
+ atts = {
24
+ 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"},
25
+ method: :get, timeout: 3000, :cache_timeout => 0, params: params
26
+ }
27
+ request = Typhoeus::Request.new("#{HOST}#{url}",atts)
28
+ hydra = Typhoeus::Hydra.new
29
+ hydra.queue(request)
30
+ hydra.run
31
+
32
+ result = $json.decode(request.response.body)
33
+ end
34
+
35
+ def self.post_date(url,access_token,params)
36
+ atts = {
37
+ 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"},
38
+ method: :post, timeout: 3000, :cache_timeout => 0, params: params
39
+ }
40
+ request = Typhoeus::Request.new("#{HOST}#{url}",atts)
41
+ hydra = Typhoeus::Hydra.new
42
+ hydra.queue(request)
43
+ hydra.run
44
+
45
+ result = $json.decode(request.response.body)
46
+ end
47
+
48
+ end
49
+
50
+ class Api
51
+ # Weibo2Plugins::Tools::Api.get_friend('1925715145','/friendships/friends.json','2.00hTG1GCDSHn2C64fbb3f2d30n2pHb')
21
52
  def self.get_friend(uid,url,access_token)
22
53
  params = {uid: uid, access_token: access_token, count: 200}
23
54
  atts = {
@@ -31,6 +62,21 @@ module Weibo2Plugins
31
62
 
32
63
  result = $json.decode(request.response.body)
33
64
  end
65
+ # Weibo2Plugins::Tools::Api.post_statuses('1925715145','/statuses/update.json','2.00hTG1GCDSHn2C64fbb3f2d30n2pHb','test')
66
+ def self.post_statuses(uid,url,access_token,status)
67
+ params = {uid: uid, access_token: access_token, status: URI.escape(status).to_json}
68
+ atts = {
69
+ 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"},
70
+ method: :post, timeout: 3000, cache_timeout: 0, params: params
71
+ }
72
+ request = Typhoeus::Request.new("#{HOST}#{url}",atts)
73
+ hydra = Typhoeus::Hydra.new
74
+ hydra.queue(request)
75
+ hydra.run
76
+
77
+ result = $json.decode(request.response.body)
78
+ end
79
+
34
80
 
35
81
  end
36
82
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weibo2_plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000 Z
12
+ date: 2012-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2