oauth2_china 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/tester.rb +18 -7
- data/lib/oauth2_china/version.rb +1 -1
- data/lib/oauth2_china.rb +54 -4
- metadata +6 -6
data/examples/tester.rb
CHANGED
@@ -1,13 +1,24 @@
|
|
1
1
|
#coding: utf-8
|
2
2
|
require 'oauth2_china'
|
3
|
+
require 'pp'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
##p res
|
5
|
+
sina = Oauth2China::Sina.new "2.00PvDQzBxMwjVD8993bb67cbOr_UYE"
|
6
|
+
#res = sina.statuses_update("ello wd")
|
7
7
|
#res = sina.statuses_upload("come on gif", "./016.gif")
|
8
|
-
|
8
|
+
mentions = sina.statuses_mentions
|
9
|
+
mentions.statuses.each do |mention|
|
10
|
+
if mention.geo?
|
11
|
+
coordinates = mention.geo.coordinates
|
12
|
+
pp coordinates
|
13
|
+
pp mention
|
14
|
+
else
|
15
|
+
pp 'no geo'
|
16
|
+
end
|
17
|
+
if mention.original_pic?
|
18
|
+
pp mention.original_pic
|
19
|
+
end
|
20
|
+
end
|
9
21
|
|
10
|
-
qq = Oauth2China::Tencent.new "88f6c1b65ff3dbd0ebdda3db123f791a", "7547D743583717EA820A834BE4B50255"
|
11
22
|
#qq = Oauth2China::Tencent.new "a92e335ad63b4d7dbf9ac9d299fe7817", "565f61c64aa43838af462b355022c562"
|
12
|
-
res = qq.statuses_update "hello world"
|
13
|
-
p res
|
23
|
+
#res = qq.statuses_update "hello world"
|
24
|
+
#p res
|
data/lib/oauth2_china/version.rb
CHANGED
data/lib/oauth2_china.rb
CHANGED
@@ -18,7 +18,7 @@ module Oauth2China
|
|
18
18
|
@conn = Faraday.new(:url => 'https://api.weibo.com') do |faraday|
|
19
19
|
faraday.request :multipart
|
20
20
|
faraday.request :url_encoded # form-encode POST params
|
21
|
-
faraday.response :logger # log requests to STDOUT
|
21
|
+
#faraday.response :logger # log requests to STDOUT
|
22
22
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
23
23
|
end
|
24
24
|
end
|
@@ -82,19 +82,69 @@ module Oauth2China
|
|
82
82
|
res = @conn.post("/2/comments/create.json", params).body
|
83
83
|
Hashie::Mash.new(JSON.parse res)
|
84
84
|
end
|
85
|
+
|
86
|
+
# since_id false int64 若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0。
|
87
|
+
# max_id false int64 若指定此参数,则返回ID小于或等于max_id的微博,默认为0。
|
88
|
+
# count false int 单页返回的记录条数,默认为50。
|
89
|
+
# page false int 返回结果的页码,默认为1。
|
90
|
+
# filter_by_author false int 作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。
|
91
|
+
# filter_by_source false int 来源筛选类型,0:全部、1:来自微博、2:来自微群,默认为0。
|
92
|
+
# filter_by_type false int 原创筛选类型,0:全部微博、1:原创的微博,默认为0。
|
93
|
+
# trim_user false int 返回值中user字段开关,0:返回完整user字段、1:user字段仅返回user_id,默认为0。
|
94
|
+
def statuses_mentions(options = {})
|
95
|
+
params = @tmpl.clone.merge(options)
|
96
|
+
res = @conn.get("/2/statuses/mentions.json", params).body
|
97
|
+
Hashie::Mash.new(JSON.parse res)
|
98
|
+
end
|
99
|
+
|
100
|
+
# since_id false int64 若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0。
|
101
|
+
# max_id false int64 若指定此参数,则返回ID小于或等于max_id的微博,默认为0。
|
102
|
+
# count false int 单页返回的记录条数,默认为50。
|
103
|
+
# page false int 返回结果的页码,默认为1。
|
104
|
+
# base_app false int 是否只获取当前应用的数据。0为否(所有数据),1为是(仅当前应用),默认为0。
|
105
|
+
# feature false int 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。
|
106
|
+
# trim_user false int 返回值中user字段开关,0:返回完整user字段、1:user字段仅返回user_id,默认为0。
|
107
|
+
def statuses_friends_timeline(options = {})
|
108
|
+
params = @tmpl.clone.merge(options)
|
109
|
+
res = @conn.get("/2/statuses/friends_timeline.json", params).body
|
110
|
+
Hashie::Mash.new(JSON.parse res)
|
111
|
+
end
|
112
|
+
|
113
|
+
# since_id false int64 若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0。
|
114
|
+
# max_id false int64 若指定此参数,则返回ID小于或等于max_id的微博,默认为0。
|
115
|
+
# count false int 单页返回的记录条数,默认为50。
|
116
|
+
# page false int 返回结果的页码,默认为1。
|
117
|
+
# base_app false int 是否只获取当前应用的数据。0为否(所有数据),1为是(仅当前应用),默认为0。
|
118
|
+
# feature false int 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。
|
119
|
+
# trim_user false int 返回值中user字段开关,0:返回完整user字段、1:user字段仅返回user_id,默认为0。
|
120
|
+
def home_timeline(options = {})
|
121
|
+
params = @tmpl.clone.merge(options)
|
122
|
+
res = @conn.get("/2/home/timeline.json", params).body
|
123
|
+
Hashie::Mash.new(JSON.parse res)
|
124
|
+
end
|
125
|
+
|
126
|
+
def place_pois_add_checkin(poiid, status, options = {})
|
127
|
+
params = @tmpl.clone.merge(options)
|
128
|
+
|
129
|
+
params.poiid = poiid
|
130
|
+
params.status = status
|
131
|
+
|
132
|
+
res = @conn.post("/2/place/pois/add_checkin.json", params).body
|
133
|
+
Hashie::Mash.new(JSON.parse res)
|
134
|
+
end
|
85
135
|
end
|
86
136
|
|
87
137
|
class Tencent < Oauth2China::Base
|
88
|
-
def initialize(access_token, openid)
|
138
|
+
def initialize(access_token, clientid, openid)
|
89
139
|
@conn = Faraday.new(:url => 'https://open.t.qq.com') do |faraday|
|
90
140
|
faraday.request :multipart
|
91
141
|
faraday.request :url_encoded # form-encode POST params
|
92
|
-
faraday.response :logger # log requests to STDOUT
|
142
|
+
#faraday.response :logger # log requests to STDOUT
|
93
143
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
94
144
|
end
|
95
145
|
|
96
146
|
@tmpl = Hashie::Mash.new({
|
97
|
-
oauth_consumer_key:
|
147
|
+
oauth_consumer_key: clientid,
|
98
148
|
access_token: access_token,
|
99
149
|
openid: openid,
|
100
150
|
clientip: '202.102.154.3',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth2_china
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
|
-
requirement: &
|
16
|
+
requirement: &70141813570320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70141813570320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hashie
|
27
|
-
requirement: &
|
27
|
+
requirement: &70141813569620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70141813569620
|
36
36
|
description: weibo client for china.
|
37
37
|
email:
|
38
38
|
- cqpanxu@gmail.com
|