kakao_rest_api 0.9.7 → 0.9.8
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.
- checksums.yaml +4 -4
- data/lib/kakao_rest_api.rb +13 -26
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc980b66d74215d5ce1dbb5901399e51bc319091
|
|
4
|
+
data.tar.gz: d690f551fc8c75b067e147f46254eba0c3e945c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b39bb51562564493c17d224884d17631e20116e3c7829c0d548f0d2b30060fa68d4ed4220bfcc788304a9b0a53036296e76bde177c1840772c818ea665f2ebb
|
|
7
|
+
data.tar.gz: b9108cd659ac6f4f813d001cb527695a1996b335251e689984f6e7a9b1013eb29db461ed4318d319b326a5577d3904f98e7693bcb6e76240e641d567a68c6c0b
|
data/lib/kakao_rest_api.rb
CHANGED
|
@@ -7,11 +7,11 @@ class KakaoRestApi
|
|
|
7
7
|
attr_accessor :app_key, :admin_key, :authorize_code, :redirect_uri
|
|
8
8
|
|
|
9
9
|
HOST_KAUTH = 'https://kauth.kakao.com'.freeze
|
|
10
|
-
HOST_KAPI
|
|
10
|
+
HOST_KAPI = 'https://kapi.kakao.com'.freeze
|
|
11
11
|
|
|
12
12
|
def initialize(app_key, admin_key, redirect_uri)
|
|
13
|
-
self.app_key
|
|
14
|
-
self.admin_key
|
|
13
|
+
self.app_key = app_key
|
|
14
|
+
self.admin_key = admin_key
|
|
15
15
|
self.redirect_uri = redirect_uri
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -21,7 +21,7 @@ class KakaoRestApi
|
|
|
21
21
|
|
|
22
22
|
def login(state = nil, encode_state = false)
|
|
23
23
|
response_type = 'code'
|
|
24
|
-
path
|
|
24
|
+
path = "/oauth/authorize?client_id=#{app_key}&redirect_uri=#{redirect_uri}&response_type=#{response_type}"
|
|
25
25
|
path.concat("&state=#{state}") unless state.nil?
|
|
26
26
|
path.concat('&encode_state=true') if encode_state
|
|
27
27
|
|
|
@@ -30,22 +30,22 @@ class KakaoRestApi
|
|
|
30
30
|
|
|
31
31
|
def token
|
|
32
32
|
query_params = {
|
|
33
|
-
grant_type:
|
|
34
|
-
client_id:
|
|
33
|
+
grant_type: 'authorization_code',
|
|
34
|
+
client_id: app_key,
|
|
35
35
|
redirect_uri: redirect_uri,
|
|
36
|
-
code:
|
|
36
|
+
code: authorize_code
|
|
37
37
|
}
|
|
38
|
-
request_url
|
|
38
|
+
request_url = "#{HOST_KAUTH}/oauth/token"
|
|
39
39
|
RestClient.post(request_url, query_params)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def refresh_token(refresh_token)
|
|
43
43
|
query_params = {
|
|
44
|
-
grant_type:
|
|
45
|
-
client_id:
|
|
44
|
+
grant_type: 'refresh_token',
|
|
45
|
+
client_id: app_key,
|
|
46
46
|
refresh_token: refresh_token
|
|
47
47
|
}
|
|
48
|
-
request_url
|
|
48
|
+
request_url = "#{HOST_KAUTH}/oauth/token"
|
|
49
49
|
RestClient.post(request_url, query_params)
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -65,19 +65,6 @@ class KakaoRestApi
|
|
|
65
65
|
KakaoUser.me access_token, property_keys, secure_resource
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
def me_with_admin(user_id, property_keys = [], secure_resource = true)
|
|
69
|
-
authorization = "KakaoAK #{admin_key}"
|
|
70
|
-
params = {
|
|
71
|
-
propertyKeys: property_keys,
|
|
72
|
-
secure_resource: secure_resource,
|
|
73
|
-
target_id_type: 'user_id',
|
|
74
|
-
target_id: user_id
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
request_url = "#{HOST_KAPI}/v1/user/me"
|
|
78
|
-
RestClient.post(request_url, params, Authorization: authorization)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
68
|
def update_profile(access_token, props = {})
|
|
82
69
|
KakaoUser.update_profile access_token, props
|
|
83
70
|
end
|
|
@@ -105,11 +92,11 @@ class KakaoRestApi
|
|
|
105
92
|
when Story::POST_TYPE_NOTE
|
|
106
93
|
Story.post_note required_params, options
|
|
107
94
|
when Story::POST_TYPE_IMAGE
|
|
108
|
-
file_paths
|
|
95
|
+
file_paths = required_params[:image_url_list]
|
|
109
96
|
required_params[:image_url_list] = upload_multi(access_token, file_paths)
|
|
110
97
|
Story.post_photo required_params, options
|
|
111
98
|
when Story::POST_TYPE_LINK
|
|
112
|
-
url
|
|
99
|
+
url = required_params[:url]
|
|
113
100
|
required_params[:link_info] = link_info(access_token, url)
|
|
114
101
|
Story.post_link required_params, options
|
|
115
102
|
end
|