oauth_china 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/oauth_china.rb +1 -0
- data/lib/oauth_china/strategies/netease.rb +22 -2
- data/lib/oauth_china/strategies/qq.rb +1 -27
- data/lib/oauth_china/version.rb +1 -1
- metadata +3 -3
data/lib/oauth_china.rb
CHANGED
@@ -31,9 +31,29 @@ module OauthChina
|
|
31
31
|
self.post("http://api.t.163.com/statuses/update.json", options)
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
#网易微博发送带图片的微博需要两个步骤:
|
35
|
+
#1.利用上传图片接口上传图片,并取得返回的image url
|
36
|
+
#2.把取来的image url放到微博的内容中,利用发微博接口发送微博。
|
37
|
+
#3.注意:如果把站外图片链接放到微博里发送不会在web页面中显示
|
35
38
|
def upload_image(content, image_path, options = {})
|
36
|
-
|
39
|
+
options = options.merge!(:pic => File.open(image_path, "rb")).to_options
|
40
|
+
image_url = parse_image_url(just_upload_image(image_path))
|
41
|
+
add_status("#{image_url} #{content}", options)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def just_upload_image(image_path)
|
47
|
+
upload("http://api.t.163.com/statuses/upload.json", :pic => File.open(image_path, "rb"))
|
48
|
+
end
|
49
|
+
|
50
|
+
def parse_image_url(resp)
|
51
|
+
hash_body = JSON.parse(resp.body)
|
52
|
+
if hash_body["error"]
|
53
|
+
raise hash_body["error"]
|
54
|
+
else
|
55
|
+
hash_body["upload_image_url"]
|
56
|
+
end
|
37
57
|
end
|
38
58
|
|
39
59
|
end
|
@@ -38,7 +38,6 @@ module OauthChina
|
|
38
38
|
end
|
39
39
|
|
40
40
|
#TODO
|
41
|
-
#还未实现
|
42
41
|
def upload_image(content, image_path, options = {})
|
43
42
|
add_status(content, options)
|
44
43
|
end
|
@@ -48,32 +47,7 @@ module OauthChina
|
|
48
47
|
#
|
49
48
|
# upload("http://open.t.qq.com/api/t/add_pic", options)
|
50
49
|
# end
|
51
|
-
|
52
|
-
# def upload(url, options)
|
53
|
-
# url = URI.parse(url)
|
54
|
-
# http = Net::HTTP.new(url.host, url.port)
|
55
|
-
# req = Net::HTTP::Post.new(url.request_uri)
|
56
|
-
# req = sign_without_pic_field(req, self.access_token, options)
|
57
|
-
# req = set_multipart_field(req, options)
|
58
|
-
#
|
59
|
-
# http.request(req)
|
60
|
-
#
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
# def sign_without_pic_field(req, access_token, options)
|
64
|
-
# req.set_form_data(params_without_pic_field(options))
|
65
|
-
# self.consumer.sign!(req, access_token)
|
66
|
-
# req
|
67
|
-
# end
|
68
|
-
#
|
69
|
-
# def set_multipart_field(req, params)
|
70
|
-
# multipart_post = MultipartPost.new
|
71
|
-
# multipart_post.set_form_data(req, params)
|
72
|
-
# end
|
73
|
-
#
|
74
|
-
# def params_without_pic_field(options)
|
75
|
-
# options.except(:pic)
|
76
|
-
# end
|
50
|
+
|
77
51
|
|
78
52
|
end
|
79
53
|
end
|
data/lib/oauth_china/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth_china
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hooopo
|