naver-sdk 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +21 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +530 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/naver/client.rb +42 -0
- data/lib/naver/config.rb +24 -0
- data/lib/naver/connection.rb +75 -0
- data/lib/naver/error.rb +4 -0
- data/lib/naver/map.rb +19 -0
- data/lib/naver/oauth.rb +68 -0
- data/lib/naver/objectified_hash.rb +35 -0
- data/lib/naver/papago.rb +18 -0
- data/lib/naver/profile.rb +11 -0
- data/lib/naver/sdk/version.rb +5 -0
- data/lib/naver/sdk.rb +23 -0
- data/lib/naver/search.rb +90 -0
- data/lib/naver/shortenurl.rb +12 -0
- data/naver-sdk.gemspec +32 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cd7d3ae9b6a7d99514bb6b5d850e8b9cb898f47f
|
4
|
+
data.tar.gz: e8cb9a0cef676cf66ac4522f4b9a380ede040316
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06efe4d35ccb769031e29ba89c55a3b76b0283aa5849854a61270d8d8564e8b08ea10f1ee5648cdf13ecac323165e585d1c9639669c058ef34fd3985cfb67770
|
7
|
+
data.tar.gz: bdaa29f8b2e032e634306e6a1307d503a330e4e17d8bf5b6feb57bda2e11616c7ed630c792bc9f3405cc4fca286f8b2b860dde086322ce057fc93b0db6107c58
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
|
4
|
+
cache:
|
5
|
+
bundler: true
|
6
|
+
|
7
|
+
rvm:
|
8
|
+
- 2.2.6
|
9
|
+
- 2.3.3
|
10
|
+
- 2.4.0
|
11
|
+
- jruby
|
12
|
+
- rbx-2
|
13
|
+
- ruby-head
|
14
|
+
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: jruby
|
18
|
+
- rvm: rbx-2
|
19
|
+
- rvm: ruby-head
|
20
|
+
|
21
|
+
before_install: gem install bundler -v 1.15.1
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at kimsuelim@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Surim Kim
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,530 @@
|
|
1
|
+
# NAVER SDK for Ruby
|
2
|
+
|
3
|
+
[](https://travis-ci.org/kimsuelim/naver-sdk-ruby)
|
4
|
+
[](https://coveralls.io/r/kimsuelim/naver-sdk-ruby?branch=master)
|
5
|
+
[](http://badge.fury.io/rb/naver-sdk)
|
6
|
+
|
7
|
+
A ruby client for the NAVER API. [https://developers.naver.com](https://developers.naver.com)
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem "naver-sdk"
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install naver-sdk
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
### Configuration
|
27
|
+
|
28
|
+
Before making requests, you must configure the gem with your client ID
|
29
|
+
and secret. If you are using Rails, you can do this in an initializer.
|
30
|
+
|
31
|
+
요청하기 전에 애플리케이션 등록 시 발급받은 Client ID와 Client Secret 값을 설정해주셔야 활용 가능합니다.
|
32
|
+
Rails를 사용하고 있다면 initializer에서 할 수 있습니다.
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Naver.configure do |config|
|
36
|
+
config.client_id = "YOUR CLIENT ID"
|
37
|
+
config.client_secret = "YOUR CLIENT SECRET"
|
38
|
+
config.redirect_uri = "https://your-application.com/oauth/callback"
|
39
|
+
config.timeout = 10
|
40
|
+
config.debug = false
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
## 지도
|
45
|
+
|
46
|
+
### 주소 -> 좌표 변환
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
response = Naver::Map.geocode(query: "불정로 6")
|
50
|
+
# => [#<Naver::ObjectifiedHash:70284981985920 {hash: {
|
51
|
+
"address"=>"경기도 성남시 분당구 불정로 6 NAVER그린팩토리",
|
52
|
+
"addrdetail"=>{"country"=>"대한민국", "sido"=>"경기도", "sigugun"=>"성남시 분당구", "dongmyun"=>"불정로", "rest"=>" 6 NAVER그린팩토리"},
|
53
|
+
"isRoadAddress"=>true,
|
54
|
+
"point"=>{"x"=>127.1052133, "y"=>37.3595316}}}
|
55
|
+
]
|
56
|
+
|
57
|
+
puts response[0].address
|
58
|
+
# => 경기도 성남시 분당구 불정로 6 NAVER그린팩토리
|
59
|
+
|
60
|
+
puts response[0].addrdetail.sido
|
61
|
+
# => 경기도
|
62
|
+
```
|
63
|
+
|
64
|
+
### 좌표 -> 주소 변환
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
response = Naver::Map.reverse_geocode(lat: "127.1141382", lng: "37.3599968")
|
68
|
+
# => [#<Naver::ObjectifiedHash:70284981856220 {hash: {
|
69
|
+
"address"=>"경기도 성남시 분당구 정자동 257-1",
|
70
|
+
"addrdetail"=>{"country"=>"대한민국", "sido"=>"경기도", "sigugun"=>"성남시 분당구", "dongmyun"=>"정자동", "rest"=>"257-1"},
|
71
|
+
"isAdmAddress"=>false,
|
72
|
+
"isRoadAddress"=>false,
|
73
|
+
"point"=>{"x"=>127.1164925, "y"=>37.3597611}}
|
74
|
+
},
|
75
|
+
...
|
76
|
+
]
|
77
|
+
|
78
|
+
puts response[0].address
|
79
|
+
# => 경기도 성남시 분당구 불정로 6 NAVER그린팩토리
|
80
|
+
|
81
|
+
puts response[0].point.x
|
82
|
+
# => 127.1164925
|
83
|
+
```
|
84
|
+
|
85
|
+
## 단축URL
|
86
|
+
|
87
|
+
### url
|
88
|
+
```ruby
|
89
|
+
response = Naver::Shortenurl.url(url: "https://github.com/kimsuelim")
|
90
|
+
# => #<Naver::ObjectifiedHash:70284972276780 {hash: {
|
91
|
+
"hash"=>"Fr4K6WFj",
|
92
|
+
"url"=>"http://me2.do/Fr4K6WFj",
|
93
|
+
"orgUrl"=>"https://github.com/kimsuelim"}
|
94
|
+
}
|
95
|
+
|
96
|
+
puts response.url
|
97
|
+
# => "http://me2.do/Fr4K6WFj"
|
98
|
+
```
|
99
|
+
|
100
|
+
## 파파고
|
101
|
+
|
102
|
+
### 한글인명 - 로마자 변환
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
response = Naver::Papago.romanization(query: "김수림")
|
106
|
+
=> #<Naver::ObjectifiedHash:70284972145960 {hash: {
|
107
|
+
"sFirstName"=>"김",
|
108
|
+
"aItems"=>[
|
109
|
+
{"name"=>"Kim Soorim", "score"=>"99"},
|
110
|
+
{"name"=>"Kim Soolim", "score"=>"97"},
|
111
|
+
{"name"=>"Kim Surim", "score"=>"78"},
|
112
|
+
{"name"=>"Kim Sulim", "score"=>"76"}
|
113
|
+
]}
|
114
|
+
}
|
115
|
+
|
116
|
+
puts response.aItems[0].name
|
117
|
+
# => "Kim Soorim"
|
118
|
+
```
|
119
|
+
|
120
|
+
### 기계번역(Beta)
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
response = Naver::Papago.translate(
|
124
|
+
source: "ko",
|
125
|
+
target: "en",
|
126
|
+
text: "기술이 인간을 대체하는 것이 아니라 인간은 기술의 도움으로 더욱 창조적으로 될 것이라는 믿는다."
|
127
|
+
)
|
128
|
+
|
129
|
+
# => #<Naver::ObjectifiedHash:70362563050680 {hash: {
|
130
|
+
"translatedText"=>"To replace the technology not believe that humans are more creatively with the help of technology."
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
puts response.translatedText
|
135
|
+
# => "To replace the technology not believe that humans are more creatively with the help of technology."
|
136
|
+
```
|
137
|
+
|
138
|
+
## 검색
|
139
|
+
|
140
|
+
### 블로그
|
141
|
+
```ruby
|
142
|
+
search_results = Naver::Search.blog(query: "블로그")
|
143
|
+
# => <Naver::ObjectifiedHash:70284981057980 {hash: {
|
144
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 19:11:02 +0900", "total"=>26223046, "start"=>1, "display"=>10,
|
145
|
+
"items"=>[
|
146
|
+
{
|
147
|
+
"title"=>"<b>블로그</b>마케팅교육 어떻게 시작해야 할까요?",
|
148
|
+
"link"=>"http://blog.naver.com/roompen9030?Redirect=Log&logNo=221030193550",
|
149
|
+
"description"=>"업체를 운영하시거나 창업을 하신 모든 분들이 한번쯤은 <b>블로그</b>마케팅을 고민해보셨을 거예요. 하지만... 가장 좋은 방법은 큰 비용을 들이지 않고도 내가 스스로 <b>블로그</b>마케팅을 하는 거겠지만 어떻게 해야... ",
|
150
|
+
"bloggername"=>"호러천국",
|
151
|
+
"bloggerlink"=>"http://blog.naver.com/roompen9030",
|
152
|
+
"postdate"=>"20170616"
|
153
|
+
},
|
154
|
+
...
|
155
|
+
]
|
156
|
+
}
|
157
|
+
|
158
|
+
puts search_results.total
|
159
|
+
# => 26223041
|
160
|
+
|
161
|
+
puts search_results.items[0].bloggername
|
162
|
+
# => 호러천국
|
163
|
+
```
|
164
|
+
|
165
|
+
### 뉴스
|
166
|
+
```ruby
|
167
|
+
search_results = Naver::Search.news(query: "뉴스")
|
168
|
+
# => #<Naver::ObjectifiedHash:70284981108020 {hash: {
|
169
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 19:17:32 +0900", "total"=>31804178, "start"=>1, "display"=>10,
|
170
|
+
"items"=>[
|
171
|
+
{
|
172
|
+
"title"=>"'믿듣맘무' 마마무, 걸그룹 음원차트 평정… 멜론 누적 이용자수 94만명 돌파",
|
173
|
+
"originallink"=>"http://enews24.tving.com/news/article.asp?nsID=1221358",
|
174
|
+
"link"=>"http://news.naver.com/main/read.nhn?mode=LSD&mid=sec&sid1=106&oid=404&aid=0000180862",
|
175
|
+
"description"=>"녹아져 있는, 밉지 않은 귀여운 허세가 인상적인 큐티 허세송이다. 한편 마마무는 24일 MBC '쇼! 음악중심' 무대에 오른다. 사진 = RBW 제공 이지영 기자 [Copyright ⓒ Asia No.1 연예<b>뉴스</b> enews24.net 무단전재 및 재배포 금지]",
|
176
|
+
"pubDate"=>"Sat, 24 Jun 2017 19:15:00 +0900"
|
177
|
+
},
|
178
|
+
...
|
179
|
+
]
|
180
|
+
}
|
181
|
+
|
182
|
+
puts search_results.items[0].title
|
183
|
+
# => '믿듣맘무' 마마무, 걸그룹 음원차트 평정… 멜론 누적 이용자수 94만명 돌파
|
184
|
+
```
|
185
|
+
|
186
|
+
### 책
|
187
|
+
```ruby
|
188
|
+
search_results = Naver::Search.book(query: "책")
|
189
|
+
# => #<Naver::ObjectifiedHash:70284982544600 {hash: {
|
190
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:08:46 +0900", "total"=>555896, "start"=>1, "display"=>10,
|
191
|
+
"items"=>[
|
192
|
+
{
|
193
|
+
"title"=>"너의 이름은",
|
194
|
+
"link"=>"http://book.naver.com/bookdb/book_detail.php?bid=11463103",
|
195
|
+
"image"=>"http://bookthumb.phinf.naver.net/cover/114/631/11463103.jpg?type=m1&udate=20170512",
|
196
|
+
"author"=>"신카이 마코토",
|
197
|
+
"price"=>"11000",
|
198
|
+
"discount"=>"9900",
|
199
|
+
"publisher"=>"대원씨아이",
|
200
|
+
"pubdate"=>"20170117",
|
201
|
+
"isbn"=>"1133440053 9791133440054",
|
202
|
+
"description"=>"아직 만난 적 없는 너를, 지금부터 나는 찾으러 간다!애 니메이션 차세대 거장으로 거듭난 신카이 마코토 감독이 직접 집필한 극장 애니메이션 《너의 이름은。》의 원작 소설 『너의 이름은.』. 《언어의 정원》, 《초속 5센티미터》 등 자신의 작품을 섬세한 필체를 살려 소설화 해온 신카이 마코토 감독.... "
|
203
|
+
},
|
204
|
+
...
|
205
|
+
]
|
206
|
+
}
|
207
|
+
|
208
|
+
puts search_results.items[0].title
|
209
|
+
# => "너의 이름은"
|
210
|
+
```
|
211
|
+
|
212
|
+
### 성인 검색어 판별
|
213
|
+
```ruby
|
214
|
+
response = Naver::Search.adult(query: "성인")
|
215
|
+
puts response.adult
|
216
|
+
# => "1"
|
217
|
+
|
218
|
+
response = Naver::Search.adult(query: "청소년")
|
219
|
+
puts response.adult
|
220
|
+
# => "0"
|
221
|
+
```
|
222
|
+
|
223
|
+
### 백과 사전
|
224
|
+
```ruby
|
225
|
+
search_results = Naver::Search.encyc(query: "백과 사전")
|
226
|
+
# => #<Naver::ObjectifiedHash:70284982397080 {hash: {
|
227
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:12:58 +0900", "total"=>4332, "start"=>1, "display"=>10,
|
228
|
+
"items"=>[
|
229
|
+
{
|
230
|
+
"title"=>"<b>백과사전</b>",
|
231
|
+
"link"=>"http://terms.naver.com/entry.nhn?docId=556891&cid=46669&categoryId=46669",
|
232
|
+
"description"=>" 과학·자연 및 인간의 활동에 따른 일체의 지식을 압축 정리해서 각 사항을 가나다순(알파벳순), 분류순 또는 기타 일정한 순서로 배열하여 엮은 책. [내용] 동양, 그 가운데에서도 특히 중국에서는... ",
|
233
|
+
"thumbnail"=>"http://openapi-dbscthumb.phinf.naver.net/2644_000_9/20150328034129739_UX34MP75L.jpg/4b8709b1-60ab-47.jpg?type=m160_160"
|
234
|
+
},
|
235
|
+
...
|
236
|
+
]
|
237
|
+
}
|
238
|
+
|
239
|
+
puts search_results.items[0].title
|
240
|
+
# => "<b>백과사전</b>"
|
241
|
+
```
|
242
|
+
|
243
|
+
### 영화
|
244
|
+
```ruby
|
245
|
+
search_results = Naver::Search.movie(query: "킬빌")
|
246
|
+
# => #<Naver::ObjectifiedHash:70284982296880 {hash: {
|
247
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:15:41 +0900", "total"=>3, "start"=>1, "display"=>3,
|
248
|
+
"items"=>[
|
249
|
+
{
|
250
|
+
"title"=>"<b>킬 빌</b> - 2부",
|
251
|
+
"link"=>"http://movie.naver.com/movie/bi/mi/basic.nhn?code=37493",
|
252
|
+
"image"=>"http://imgmovie.naver.com/mdi/mit110/0374/C7493-00.jpg",
|
253
|
+
"subtitle"=>"Kill Bill: Vol. 2",
|
254
|
+
"pubDate"=>"2004",
|
255
|
+
"director"=>"쿠엔틴 타란티노|",
|
256
|
+
"actor"=>"우마 서먼|데이빗 캐러딘|",
|
257
|
+
"userRating"=>"7.48"
|
258
|
+
},
|
259
|
+
...
|
260
|
+
]
|
261
|
+
}
|
262
|
+
|
263
|
+
puts search_results.items[0].title
|
264
|
+
# => "<b>킬 빌</b> - 2부"
|
265
|
+
```
|
266
|
+
|
267
|
+
### 카페글
|
268
|
+
```ruby
|
269
|
+
search_results = Naver::Search.cafearticle(query: "카페글")
|
270
|
+
# => #<Naver::ObjectifiedHash:70284982183260 {hash: {
|
271
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:17:56 +0900", "total"=>216425, "start"=>1, "display"=>10,
|
272
|
+
"items"=>[
|
273
|
+
{
|
274
|
+
"title"=>"예전 <b>카페글</b> 복습하기",
|
275
|
+
"link"=>"http://cafe.naver.com/cosmicordering/26633",
|
276
|
+
"description"=>"많아서 공유글도 나쁘지는 않지만 요즘 글들은 어째 예전 거보다 질적인 측면에서 많이 떨어진다는 생각이... 이것만큼은 꼭 읽으면 도움된다 하는 글들 위주로 쪽지, 혹은 <b>카페글</b>로 올려드릴게요. :) 그럼 한 주도 화잇팅~~~ ",
|
277
|
+
"cafename"=>"우루사 _ 우주 택배를 받고 소원을 이...",
|
278
|
+
"cafeurl"=>"http://cafe.ㅜver.com/cosmicordering"
|
279
|
+
},
|
280
|
+
...
|
281
|
+
]
|
282
|
+
}
|
283
|
+
|
284
|
+
puts search_results.items[0].title
|
285
|
+
# => "예전 <b>카페글</b> 복습하기"
|
286
|
+
```
|
287
|
+
|
288
|
+
### 지식 iN
|
289
|
+
```ruby
|
290
|
+
search_results = Naver::Search.kin(query: "지식인")
|
291
|
+
# => #<Naver::ObjectifiedHash:70284982086840 {hash: {
|
292
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:20:19 +0900", "total"=>6931274, "start"=>1, "display"=>10,
|
293
|
+
"items"=>[
|
294
|
+
{
|
295
|
+
"title"=>"<b>지식인</b> 디렉토리 변경",
|
296
|
+
"link"=>"http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=1060101&docId=278622531&qb기KeA7Iud7J24&enc=utf8§ion=kin.qna&rank=1&search_sort=0&spq=0",
|
297
|
+
"description"=>"<b>지식인</b> 디렉토리 변경 어떻게 하나요? 첫번째 화면에서 디렉토리 변경 요청을... 아오 <b>지식인</b> 서비스 진짜 불편해졌네 디렉토리 이동 권한이 없는... 분야별<b>지식인</b> 유저에게는 디렉토리 이동 방능이 있어 원하신다면 확인 후 제가... "
|
298
|
+
},
|
299
|
+
...
|
300
|
+
]
|
301
|
+
}
|
302
|
+
|
303
|
+
puts search_results.items[0].title
|
304
|
+
# => "<b>지식인</b> 디렉토리 변경"
|
305
|
+
```
|
306
|
+
|
307
|
+
### 지역
|
308
|
+
```ruby
|
309
|
+
search_results = Naver::Search.local(query: "제주도")
|
310
|
+
# => #<Naver::ObjectifiedHash:70284981059020 {hash: {
|
311
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:51:22 +0900", "total"=>75791, "start"=>1, "display"=>10,
|
312
|
+
"items"=>[
|
313
|
+
{
|
314
|
+
"title"=>"제주특별자치도청",
|
315
|
+
"link"=>"http://www.jeju.go.kr/",
|
316
|
+
"category"=>"공공,사회기관>도청",
|
317
|
+
"description"=>"제주 뉴스, 생활민원, 여권발급, 문화, <b>제주도</b> 관광, 산업경제, 복지, 여성 정보 수록.",
|
318
|
+
"telephone"=>"",
|
319
|
+
"address"=>"제주특별자치도 제주시 연동 312-1 ",
|
320
|
+
"roadAddress"=>"제주특별자치도 제주시 문연로 6 ",
|
321
|
+
"mapx"=>"260641",
|
322
|
+
"mapy"=>"100237"
|
323
|
+
},
|
324
|
+
...
|
325
|
+
]
|
326
|
+
}
|
327
|
+
|
328
|
+
puts search_results.items[0].title
|
329
|
+
# => "제주특별자치도청"
|
330
|
+
```
|
331
|
+
|
332
|
+
### 오타변환
|
333
|
+
```ruby
|
334
|
+
response = Naver::Search.errata(query: "집밥")
|
335
|
+
puts response.errata
|
336
|
+
# => ""
|
337
|
+
|
338
|
+
response = Naver::Search.errata(query: "wlqqkq")
|
339
|
+
puts response.errata
|
340
|
+
# => "집밥"
|
341
|
+
```
|
342
|
+
|
343
|
+
### 웹문서
|
344
|
+
```ruby
|
345
|
+
search_results = Naver::Search.webkr(query: "웹문서")
|
346
|
+
# => #<Naver::ObjectifiedHash:70284981547180 {hash: {
|
347
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:53:29 +0900", "total"=>1904994, "start"=>1, "display"=>10,
|
348
|
+
"items"=>[
|
349
|
+
{
|
350
|
+
"title"=>"카카오톡 <b>웹문서</b> 수집 인정 "다음 검색 연동 중단" - 오마이뉴스",
|
351
|
+
"link"=>"http://www.ohmynews.com/NWS_Web/View/at_pg.aspx?CNTN_CD=A0002213337",
|
352
|
+
"description"=>"[보도 후] 카카오 "1월부터 검색 노출, <오마이뉴스> 보도 우려 반영해 중지""
|
353
|
+
},
|
354
|
+
...
|
355
|
+
]
|
356
|
+
}
|
357
|
+
|
358
|
+
puts search_results.items[0].title
|
359
|
+
# => "카카오톡 <b>웹문서</b> 수집 인정 "다음 검색 연동 중단" - 오마이뉴스"
|
360
|
+
```
|
361
|
+
|
362
|
+
### 이미지
|
363
|
+
```ruby
|
364
|
+
search_results = Naver::Search.image(query: "이미지")
|
365
|
+
# => #<Naver::ObjectifiedHash:70284981346800 {hash: {
|
366
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:54:58 +0900", "total"=>1627087, "start"=>1, "display"=>10,
|
367
|
+
"items"=>[
|
368
|
+
{
|
369
|
+
"title"=>"볼매뿌뿌's StyleShare",
|
370
|
+
"link"=>"https://usercontents-a.styleshare.kr/images/9764328/original",
|
371
|
+
"thumbnail"=>"http://tv02.search.naver.net/ugc?q=https://usercontents-a.styleshare.kr/images/9764328/original",
|
372
|
+
"sizeheight"=>"285",
|
373
|
+
"sizewidth"=>"420"
|
374
|
+
},
|
375
|
+
...
|
376
|
+
]
|
377
|
+
}
|
378
|
+
|
379
|
+
puts search_results.items[0].title
|
380
|
+
# => "볼매뿌뿌's StyleShare"
|
381
|
+
```
|
382
|
+
|
383
|
+
### 쇼핑
|
384
|
+
```ruby
|
385
|
+
search_results = Naver::Search.shop(query: "쇼핑")
|
386
|
+
# => #<Naver::ObjectifiedHash:70284981152140 {hash: {
|
387
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:56:19 +0900", "total"=>8895965, "start"=>1, "display"=>10,
|
388
|
+
"items"=>[
|
389
|
+
{
|
390
|
+
"title"=>"팩앤롤 접이식 휴대용 핸드 <b>쇼핑</b>카트",
|
391
|
+
"link"=>"http://shopping.naver.com/gate.nhn?id=11449581836",
|
392
|
+
"image"=>"http://shopping.phinf.naver.net/main_1144958/11449581836.2.jpg",
|
393
|
+
"lprice"=>"10400",
|
394
|
+
"hprice"=>"0",
|
395
|
+
"mallName"=>"베이직기프트",
|
396
|
+
"productId"=>"11449581836",
|
397
|
+
"productType"=>"2"
|
398
|
+
},
|
399
|
+
...
|
400
|
+
]
|
401
|
+
}
|
402
|
+
|
403
|
+
puts search_results.items[0].title
|
404
|
+
# => "팩앤롤 접이식 휴대용 핸드 <b>쇼핑</b>카트"
|
405
|
+
```
|
406
|
+
|
407
|
+
### 전문자료
|
408
|
+
```ruby
|
409
|
+
search_results = Naver::Search.doc(query: "전문자료")
|
410
|
+
# => #<Naver::ObjectifiedHash:70284980468480 {hash: {
|
411
|
+
"lastBuildDate"=>"Sat, 24 Jun 2017 20:57:34 +0900", "total"=>41554, "start"=>1, "display"=>10,
|
412
|
+
"items"=>[
|
413
|
+
{
|
414
|
+
"title"=>"이미지 검색 기능을 가진 문서간 <b>전문자료</b>의 유사도 검색 시스템",
|
415
|
+
"link"=>"http://academic.naver.com/view.nhn?doc_id=189708176",
|
416
|
+
"description"=>"The full-text document similarity retrieval system including image retrieval 표제지\n목차\n국문초록 9\nABSTRACT 11\n제1장 서"
|
417
|
+
},
|
418
|
+
...
|
419
|
+
]
|
420
|
+
}
|
421
|
+
|
422
|
+
puts search_results.items[0].title
|
423
|
+
# => "이미지 검색 기능을 가진 문서간 <b>전문자료</b>의 유사도 검색 시스템"
|
424
|
+
```
|
425
|
+
|
426
|
+
## Authentication
|
427
|
+
|
428
|
+
네이버 아이디로 로그인 API는 네이버 로그인 인증 요청 API, 접근 토큰 발급/갱신/삭제 요청API로 구성되어 있습니다.
|
429
|
+
|
430
|
+
### OAuth access tokens
|
431
|
+
|
432
|
+
네이버 아이디로 로그인 API는 네이버 로그인 인증 요청 API, 접근 토큰 발급/갱신/삭제 요청API로 구성되어 있습니다.
|
433
|
+
네이버 로그인 인증 요청 API는 여러분의 웹 또는 앱에 네이버 로그인 화면을 띄우는 API입니다.
|
434
|
+
|
435
|
+
```ruby
|
436
|
+
oauth = Naver::Oauth.new(redirect_uri: "http://127.0.0.1/oauth/callback")
|
437
|
+
auth_url = oauth.authorization_url
|
438
|
+
puts auth_url
|
439
|
+
# => https://nid.naver.com/oauth2.0/authorize?client_id=GssyV0tCqRYPMRkDKsgG&redirect_uri=http%3A%2F%2F127.0.0.1%2Foauth%2Fcallback&response_type=code&scope=public
|
440
|
+
```
|
441
|
+
|
442
|
+
Upon authorization, Naver will return to you an authentication code via your OAuth
|
443
|
+
callback handler. With that you can generate an access token:
|
444
|
+
|
445
|
+
이용자가 네이버 회원 인증에 성공하면 API로부터 받은 code 값을 이용해서 접근 토큰 발급 요청 API를 호출합니다.
|
446
|
+
|
447
|
+
```ruby
|
448
|
+
oauth = Naver::Oauth.new(redirect_uri: "http://127.0.0.1/oauth/callback")
|
449
|
+
oauth.authorize!("bdIdbpkuTwzk06Y3")
|
450
|
+
oauth.extract_token
|
451
|
+
# => {
|
452
|
+
"token_type"=>"bearer",
|
453
|
+
"access_token"=>"AAAAOrmgLwPV1AcF5UBThDNkruDPEMsAJ7gyyRneAgpwAPgdm2MQj1EYOiQ9femIhs9fGW2I2PNUgrc1ZFJuy5lFo6M=",
|
454
|
+
"refresh_token"=>"fXKPyKGM2zfAxfgrDQKBA60CKsM8h9BlfqisQvtTiiWnwF5vYlAghIBSu6WvNrSmDLCCmKrfVFipEbJurOxFLoW6NdohlIqCp4mSdviiHZxLTYR0aPwnbxWmkByk70ZisuX3A",
|
455
|
+
"expires_at"=>1498212486
|
456
|
+
}
|
457
|
+
|
458
|
+
response = Naver::Profile.me
|
459
|
+
# => {
|
460
|
+
"nickname"=>"갈루트",
|
461
|
+
"enc_id"=>"86744e27d4bfdb3cddb478293d295cf783ce9ed41f0ad7687bac26e97a1ed1b4",
|
462
|
+
"profile_image"=>"https://phinf.pstatic.net/contact/52/2016/2/11/kimsuerim_1455194287821.jpg",
|
463
|
+
"age"=>"30-39",
|
464
|
+
"gender"=>"M",
|
465
|
+
"id"=>"48189785",
|
466
|
+
"name"=>"JINxx",
|
467
|
+
"email"=>"kimsuerim@naver.com",
|
468
|
+
"birthday"=>"01-08"
|
469
|
+
}
|
470
|
+
|
471
|
+
puts response.nickname
|
472
|
+
# => "갈루트"
|
473
|
+
```
|
474
|
+
|
475
|
+
접근 토큰 발급 요청 API를 통해 받은 접근 토큰(access token) 값은 다음과 같이 회원 프로필 조회를 비롯하여 여러가지 로그인 오픈 API를 호출하는데 사용할 수 있습니다.
|
476
|
+
|
477
|
+
## Advanced usage
|
478
|
+
|
479
|
+
Since naver-sdk employs [Faraday][faraday] under the hood, some behavior can be
|
480
|
+
extended via middleware.
|
481
|
+
|
482
|
+
### Debugging
|
483
|
+
|
484
|
+
Often, it helps to know what naver-sdk is doing under the hood. You can add a
|
485
|
+
logger to the middleware that enables you to peek into the underlying HTTP
|
486
|
+
traffic:
|
487
|
+
|
488
|
+
```ruby
|
489
|
+
Naver.configure do |config|
|
490
|
+
config.debug = true
|
491
|
+
end
|
492
|
+
Naver::Search.blog(query: "집밥")
|
493
|
+
```
|
494
|
+
```
|
495
|
+
I, [2017-06-24T11:59:40.920421 #54253] INFO -- : get https://openapi.naver.com/v1/search/blog?query=%EC%A7%91%EB%B0%A5
|
496
|
+
D, [2017-06-24T11:59:40.920569 #54253] DEBUG -- request: User-Agent: "NAVER SDK Ruby Gem 0.1.0"
|
497
|
+
X-Naver-Client-Id: "GssyV0tCqRYPMRkDKsgG"
|
498
|
+
X-Naver-Client-Secret: "ScVEl_cDJA"
|
499
|
+
I, [2017-06-24T11:59:41.182547 #54253] INFO -- Status: 200
|
500
|
+
D, [2017-06-24T11:59:41.182674 #54253] DEBUG -- response: server: "nginx"
|
501
|
+
date: "Sat, 24 Jun 2017 02:59:39 GMT"
|
502
|
+
content-type: "application/json;charset=UTF-8"
|
503
|
+
transfer-encoding: "chunked"
|
504
|
+
connection: "close"
|
505
|
+
vary: "Accept-Encoding"
|
506
|
+
x-powered-by: "Naver"
|
507
|
+
cache-control: "no-cache, no-store, must-revalidate"
|
508
|
+
pragma: "no-cache"
|
509
|
+
...
|
510
|
+
```
|
511
|
+
|
512
|
+
## Development
|
513
|
+
|
514
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
515
|
+
|
516
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
517
|
+
|
518
|
+
## Contributing
|
519
|
+
|
520
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kimsuelim/naver-sdk-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
521
|
+
|
522
|
+
## License
|
523
|
+
|
524
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
525
|
+
|
526
|
+
## Code of Conduct
|
527
|
+
|
528
|
+
Everyone interacting in the Naver::Sdk project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kimsuelim/naver-sdk-ruby/blob/master/CODE_OF_CONDUCT.md).
|
529
|
+
|
530
|
+
[Faraday]: https://github.com/lostisland/faraday
|