twicas_stream 1.0.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 +5 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +296 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/get_categories.rb +38 -0
- data/examples/get_comments.rb +41 -0
- data/examples/get_movie_info.rb +38 -0
- data/examples/get_user_info.rb +34 -0
- data/examples/search_live_movies.rb +44 -0
- data/examples/search_users.rb +43 -0
- data/examples/verify_credentials.rb +50 -0
- data/lib/twicas_stream/category.rb +54 -0
- data/lib/twicas_stream/comment.rb +76 -0
- data/lib/twicas_stream/live_thumbnail.rb +9 -0
- data/lib/twicas_stream/movie.rb +69 -0
- data/lib/twicas_stream/request_header.rb +35 -0
- data/lib/twicas_stream/search.rb +178 -0
- data/lib/twicas_stream/supporter.rb +24 -0
- data/lib/twicas_stream/twicas_api_object/app.rb +18 -0
- data/lib/twicas_stream/twicas_api_object/category.rb +31 -0
- data/lib/twicas_stream/twicas_api_object/comment.rb +23 -0
- data/lib/twicas_stream/twicas_api_object/error.rb +18 -0
- data/lib/twicas_stream/twicas_api_object/movie.rb +36 -0
- data/lib/twicas_stream/twicas_api_object/sub_category.rb +24 -0
- data/lib/twicas_stream/twicas_api_object/supporter_user.rb +9 -0
- data/lib/twicas_stream/twicas_api_object/user.rb +26 -0
- data/lib/twicas_stream/user.rb +39 -0
- data/lib/twicas_stream/version.rb +6 -0
- data/lib/twicas_stream.rb +122 -0
- data/twicas_stream.gemspec +40 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d657ce62377fdadac0733f9e3419092332e3484f
|
4
|
+
data.tar.gz: 64e75337098cd48153c11576abbb3f664c88f767
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b46a27061c258843864d9b1fdb03db741892f121f5da735a582f9ba33235b22cdd07e1fb3a2bec28c611d229f2afdcc37fd7f7b8d862b302f32b947bd693fcf
|
7
|
+
data.tar.gz: '0299009ee34a060b34f3dc51ded4e8266db96278f1499ef9519e91d8014e20c350624f322be71722ff95807c0c150f801942f3c551ca7221ff463e0896f8901b'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Yuya Sato
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,296 @@
|
|
1
|
+
# twicas_stream
|
2
|
+
|
3
|
+
twicas_stream provides simple Ruby access to [TwitCasting](https://twitcasting.tv/) API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```rb
|
8
|
+
gem install twicas_stream
|
9
|
+
```
|
10
|
+
|
11
|
+
## Documentation / Help
|
12
|
+
|
13
|
+
- [Developer API](https://twitcasting.tv/indexapi.php)
|
14
|
+
- [API Documentation (APIv2)](http://apiv2-doc.twitcasting.tv/)
|
15
|
+
|
16
|
+
## Preparation before using
|
17
|
+
|
18
|
+
Before using twicas_stream, we need to get access token in order to access TwitCasting API (APIv2).
|
19
|
+
Flow is as below.
|
20
|
+
|
21
|
+
1. Registration
|
22
|
+
Create new application, getting access token need 'ClientID' and 'ClientSecret'.
|
23
|
+
2. Get Access Token
|
24
|
+
TwitCasting API (APIv2) provides two types of authorization flow.
|
25
|
+
For more information, please refer to API Documentation (APIv2).
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
### Get Movie Info
|
30
|
+
|
31
|
+
Get comments of movie id which you set
|
32
|
+
|
33
|
+
```rb
|
34
|
+
# (*) following data are just example
|
35
|
+
|
36
|
+
TwicasStream.configure do |request_header|
|
37
|
+
#request_header.api_version
|
38
|
+
# => default is '2.0'
|
39
|
+
#request_header.accept_encoding
|
40
|
+
# => default is 'application/json'
|
41
|
+
# Above value don't need to change, default setting must be enough.
|
42
|
+
|
43
|
+
request_header.access_token = 'xxx'
|
44
|
+
# => you must set access token before using.
|
45
|
+
end
|
46
|
+
|
47
|
+
movie_id = '189037369'
|
48
|
+
api = TwicasStream::Movie::GetMovieInfo.new(movie_id)
|
49
|
+
movie_info = api.response[:movie]
|
50
|
+
|
51
|
+
p movie_info[:title]
|
52
|
+
# => 'ライブ #189037369'
|
53
|
+
p movie_info[:subtitle]
|
54
|
+
# => 'ライブ配信中!'
|
55
|
+
p movie_info[:current_view_count]
|
56
|
+
# => 20848
|
57
|
+
p movie_info[:total_view_count]
|
58
|
+
# => 20848
|
59
|
+
p api.response[:tags]
|
60
|
+
# => ['人気', 'コンティニュー中', 'レベル40+', '初見さん大歓迎', 'まったり', '雑談']
|
61
|
+
```
|
62
|
+
|
63
|
+
### Get Comments
|
64
|
+
|
65
|
+
Get comments of movie id which you set
|
66
|
+
|
67
|
+
```rb
|
68
|
+
# (*) following data are just example
|
69
|
+
|
70
|
+
TwicasStream.configure do |request_header|
|
71
|
+
request_header.access_token = 'xxx'
|
72
|
+
end
|
73
|
+
|
74
|
+
movie_id = '189037369'
|
75
|
+
api = TwicasStream::Comment::GetComments.new(movie_id)
|
76
|
+
comments = api.response[:comments]
|
77
|
+
|
78
|
+
p comments.first[:from_user][:name]
|
79
|
+
# => 'ツイキャス公式'
|
80
|
+
p comments.first[:from_user][:screen_id]
|
81
|
+
# => 'twitcasting_jp'
|
82
|
+
p comments.first[:message]
|
83
|
+
# => 'モイ!'
|
84
|
+
p comments.first[:created]
|
85
|
+
# => 1479579471
|
86
|
+
# (**) unix timestamp
|
87
|
+
```
|
88
|
+
|
89
|
+
For more usage, please refer to 'examples' directory.
|
90
|
+
There are some example source code in there, and help you to understand more.
|
91
|
+
|
92
|
+
## Support Request List
|
93
|
+
|
94
|
+
Current version supports following requests.
|
95
|
+
|
96
|
+
| Classification | Request | Support |
|
97
|
+
|:---------------|:-------------------------|:------------:|
|
98
|
+
| User | Get User Info | Support |
|
99
|
+
| | Verify Credentials | Support |
|
100
|
+
| Live Thumbnail | Get Live Thumbnail Image | Not Support |
|
101
|
+
| Movie | Get Movie Info | Support |
|
102
|
+
| | Get Movies by User | Not Support |
|
103
|
+
| | Get Current Live | Not Support |
|
104
|
+
| Comment | Get Comments | Support |
|
105
|
+
| | Post Comment | Not Support |
|
106
|
+
| | Delete Comment | Not Support |
|
107
|
+
| Supporter | Get Supporting Status | Not Support |
|
108
|
+
| | Support User | Not Support |
|
109
|
+
| | Unsupport User | Not Support |
|
110
|
+
| | Supporting List | Not Support |
|
111
|
+
| | Supporter List | Not Support |
|
112
|
+
| Category | Get Categories | Support |
|
113
|
+
| Search | Search Users | Support |
|
114
|
+
| | Search Live Movies | Support |
|
115
|
+
|
116
|
+
---
|
117
|
+
|
118
|
+
## Appendix
|
119
|
+
|
120
|
+
Here is for developer of twicas_stream
|
121
|
+
|
122
|
+
### Preparation before developing
|
123
|
+
|
124
|
+
Before develop twicas_stream, we need to prepare as below.
|
125
|
+
Because example srouce code and test code need access
|
126
|
+
|
127
|
+
1. Create '/config' directory
|
128
|
+
2. Create 'access_token.txt' in there
|
129
|
+
3. Write your access token in that file
|
130
|
+
|
131
|
+
### twicas_stream
|
132
|
+
|
133
|
+
```rb
|
134
|
+
module TwicasStream
|
135
|
+
module TwicasApiObject
|
136
|
+
class App
|
137
|
+
end
|
138
|
+
|
139
|
+
class User
|
140
|
+
end
|
141
|
+
|
142
|
+
class Movie
|
143
|
+
end
|
144
|
+
|
145
|
+
class Comment
|
146
|
+
end
|
147
|
+
|
148
|
+
class SupporterUser
|
149
|
+
end
|
150
|
+
|
151
|
+
class Category
|
152
|
+
end
|
153
|
+
|
154
|
+
class SubCategory
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
module User
|
159
|
+
class GetUserInfo
|
160
|
+
end
|
161
|
+
|
162
|
+
class VerifyCredentials
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
module LiveThumbnail
|
167
|
+
class GetLiveThumbnailImage
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
module Movie
|
172
|
+
class GetMovieInfo
|
173
|
+
end
|
174
|
+
|
175
|
+
class GetMoviesbyUser
|
176
|
+
end
|
177
|
+
|
178
|
+
class GetCurrentLive
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
module Comment
|
183
|
+
class GetComments
|
184
|
+
end
|
185
|
+
|
186
|
+
class PostComment
|
187
|
+
end
|
188
|
+
|
189
|
+
class DeleteComment
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
module Supporter
|
194
|
+
class GetSupportingStatus
|
195
|
+
end
|
196
|
+
|
197
|
+
class SupportUser
|
198
|
+
end
|
199
|
+
|
200
|
+
class UnsupportUser
|
201
|
+
end
|
202
|
+
|
203
|
+
class SupportingList
|
204
|
+
end
|
205
|
+
|
206
|
+
class SupporterList
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
module Category
|
211
|
+
class GetCategories
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
module Search
|
216
|
+
class SearchUsers
|
217
|
+
end
|
218
|
+
|
219
|
+
class SearchLiveMovies
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
```
|
224
|
+
|
225
|
+
### Twicas API Object
|
226
|
+
|
227
|
+
- App
|
228
|
+
- User
|
229
|
+
- Movie
|
230
|
+
- Comment
|
231
|
+
- SupporterUser
|
232
|
+
- Category
|
233
|
+
- SubCategory
|
234
|
+
- Error
|
235
|
+
|
236
|
+
### Directory Structure
|
237
|
+
|
238
|
+
```
|
239
|
+
/
|
240
|
+
├─ /config
|
241
|
+
│ └─ access_token.txt
|
242
|
+
├─ /examples
|
243
|
+
│ ├─ get_categories.rb
|
244
|
+
│ ├─ get_comments.rb
|
245
|
+
│ ├─ get_movie_info.rb
|
246
|
+
│ ├─ get_user_info.rb
|
247
|
+
│ ├─ search_live_movies.rb
|
248
|
+
│ ├─ search_users.rb
|
249
|
+
│ └─ verify_credentials.rb
|
250
|
+
├─ /lib
|
251
|
+
│ ├─ /twicas_stream
|
252
|
+
│ │ ├─ /twicas_api_object
|
253
|
+
│ │ │ ├─ app.rb
|
254
|
+
│ │ │ ├─ user.rb
|
255
|
+
│ │ │ ├─ movie.rb
|
256
|
+
│ │ │ ├─ comment.rb
|
257
|
+
│ │ │ ├─ supporter_user.rb
|
258
|
+
│ │ │ ├─ category.rb
|
259
|
+
│ │ │ └─ sub_category.rb
|
260
|
+
│ │ ├─ category.rb
|
261
|
+
│ │ ├─ comment.rb
|
262
|
+
│ │ ├─ live_thumbnail.rb
|
263
|
+
│ │ ├─ movie.rb
|
264
|
+
│ │ ├─ request_header.rb
|
265
|
+
│ │ ├─ search.rb
|
266
|
+
│ │ ├─ support.rb
|
267
|
+
│ │ ├─ user.rb
|
268
|
+
│ │ └─ version.rb
|
269
|
+
│ └─ twicas_stream.rb
|
270
|
+
├─ /spec
|
271
|
+
│ ├─ /twicas_stream
|
272
|
+
│ │ ├─ category_spec.rb
|
273
|
+
│ │ ├─ comment_spec.rb
|
274
|
+
│ │ ├─ movie_spec.rb
|
275
|
+
│ │ ├─ search_spec.rb
|
276
|
+
│ │ └─ user_spec.rb
|
277
|
+
│ └─ spec_helper.rb
|
278
|
+
│ └─ twicas_stream_spec.rb
|
279
|
+
├─ LICENSE
|
280
|
+
└─ README.md
|
281
|
+
```
|
282
|
+
|
283
|
+
### Test
|
284
|
+
|
285
|
+
#### execution of all test
|
286
|
+
|
287
|
+
```rb
|
288
|
+
ruby Test.rb
|
289
|
+
```
|
290
|
+
|
291
|
+
#### execution of each test
|
292
|
+
|
293
|
+
```rb
|
294
|
+
ruby TestUser.rb
|
295
|
+
```
|
296
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "twicas_stream"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/twicas_stream')
|
6
|
+
|
7
|
+
TwicasStream.configure do |request_header|
|
8
|
+
#request_header.access_token = File.read(File.expand_path(File.dirname(__FILE__) + '/../config/access_token.txt'))
|
9
|
+
# => for developer
|
10
|
+
|
11
|
+
request_header.access_token = 'xxx'# put your access token here
|
12
|
+
end
|
13
|
+
|
14
|
+
lang = 'ja'
|
15
|
+
api = TwicasStream::Category::GetCategories.new(lang)
|
16
|
+
categories = api.response[:categories]
|
17
|
+
|
18
|
+
exit(0) unless api.response[:error].nil?
|
19
|
+
|
20
|
+
STDOUT.puts
|
21
|
+
|
22
|
+
STDOUT.puts '--------------------------------'
|
23
|
+
STDOUT.puts 'category name'
|
24
|
+
STDOUT.puts
|
25
|
+
STDOUT.puts ' sub category name'
|
26
|
+
STDOUT.puts '--------------------------------'
|
27
|
+
categories.each{ |category|
|
28
|
+
STDOUT.puts category[:name]
|
29
|
+
STDOUT.puts
|
30
|
+
category[:sub_categories].each{ |sub_category|
|
31
|
+
STDOUT.puts ' ' + sub_category[:name]
|
32
|
+
}
|
33
|
+
STDOUT.puts '--------------------------------'
|
34
|
+
}
|
35
|
+
|
36
|
+
STDOUT.puts
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/twicas_stream')
|
6
|
+
|
7
|
+
TwicasStream.configure do |request_header|
|
8
|
+
#request_header.access_token = File.read(File.expand_path(File.dirname(__FILE__) + '/../config/access_token.txt'))
|
9
|
+
# => for developer
|
10
|
+
|
11
|
+
request_header.access_token = 'xxx'# put your access token here
|
12
|
+
end
|
13
|
+
|
14
|
+
movie_id = '189037369'
|
15
|
+
api = TwicasStream::Comment::GetComments.new(movie_id)
|
16
|
+
comments = api.response[:comments]
|
17
|
+
|
18
|
+
exit(0) unless api.response[:error].nil?
|
19
|
+
|
20
|
+
STDOUT.puts
|
21
|
+
|
22
|
+
STDOUT.puts 'Movie ID is ' + api.response[:movie_id]
|
23
|
+
STDOUT.puts
|
24
|
+
|
25
|
+
STDOUT.puts '--------------------------------'
|
26
|
+
STDOUT.puts 'name' + ' ' + '(' + '@' + 'screen_id' + ')'
|
27
|
+
STDOUT.puts
|
28
|
+
STDOUT.puts 'message'
|
29
|
+
STDOUT.puts 'created time'
|
30
|
+
STDOUT.puts '--------------------------------'
|
31
|
+
comments.each{ |comment|
|
32
|
+
STDOUT.puts comment[:from_user][:name] + ' ' + '(' + '@' + comment[:from_user][:screen_id] + ')'
|
33
|
+
STDOUT.puts
|
34
|
+
STDOUT.puts comment[:message]
|
35
|
+
STDOUT.puts Time.at(comment[:created])
|
36
|
+
STDOUT.puts '--------------------------------'
|
37
|
+
}
|
38
|
+
|
39
|
+
STDOUT.puts
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/twicas_stream')
|
6
|
+
|
7
|
+
TwicasStream.configure do |request_header|
|
8
|
+
#request_header.access_token = File.read(File.expand_path(File.dirname(__FILE__) + '/../config/access_token.txt'))
|
9
|
+
# => for developer
|
10
|
+
|
11
|
+
request_header.access_token = 'xxx'# put your access token here
|
12
|
+
end
|
13
|
+
|
14
|
+
movie_id = '189037369'
|
15
|
+
api = TwicasStream::Movie::GetMovieInfo.new(movie_id)
|
16
|
+
movie_info = api.response[:movie]
|
17
|
+
|
18
|
+
exit(0) unless api.response[:error].nil?
|
19
|
+
|
20
|
+
STDOUT.puts
|
21
|
+
|
22
|
+
STDOUT.puts 'Movie ID is ' + movie_info[:id]
|
23
|
+
STDOUT.puts
|
24
|
+
|
25
|
+
STDOUT.puts '<Title>'
|
26
|
+
STDOUT.puts movie_info[:title] + ' ~ ' + movie_info[:subtitle]
|
27
|
+
STDOUT.puts
|
28
|
+
|
29
|
+
STDOUT.puts '<Tags>'
|
30
|
+
STDOUT.puts api.response[:tags]
|
31
|
+
STDOUT.puts
|
32
|
+
|
33
|
+
STDOUT.puts 'Current View Count = ' + movie_info[:current_view_count].to_s
|
34
|
+
STDOUT.puts 'Total View Count = ' + movie_info[:total_view_count].to_s
|
35
|
+
|
36
|
+
STDOUT.puts
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/twicas_stream')
|
6
|
+
|
7
|
+
TwicasStream.configure do |request_header|
|
8
|
+
#request_header.access_token = File.read(File.expand_path(File.dirname(__FILE__) + '/../config/access_token.txt'))
|
9
|
+
# => for developer
|
10
|
+
|
11
|
+
request_header.access_token = 'xxx'# put your access token here
|
12
|
+
end
|
13
|
+
|
14
|
+
user_id = 'twitcasting_jp'
|
15
|
+
api = TwicasStream::User::GetUserInfo.new(user_id)
|
16
|
+
user_info = api.response[:user]
|
17
|
+
|
18
|
+
exit(0) unless api.response[:error].nil?
|
19
|
+
|
20
|
+
STDOUT.puts
|
21
|
+
|
22
|
+
STDOUT.puts '<Name>'
|
23
|
+
STDOUT.puts user_info[:name]
|
24
|
+
STDOUT.puts
|
25
|
+
|
26
|
+
STDOUT.puts '<Screen ID>'
|
27
|
+
STDOUT.puts user_info[:screen_id]
|
28
|
+
STDOUT.puts
|
29
|
+
|
30
|
+
STDOUT.puts '<Profile>'
|
31
|
+
STDOUT.puts user_info[:profile]
|
32
|
+
STDOUT.puts
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/twicas_stream')
|
6
|
+
|
7
|
+
TwicasStream.configure do |request_header|
|
8
|
+
#request_header.access_token = File.read(File.expand_path(File.dirname(__FILE__) + '/../config/access_token.txt'))
|
9
|
+
# => for developer
|
10
|
+
|
11
|
+
request_header.access_token = 'xxx'# put your access token here
|
12
|
+
end
|
13
|
+
|
14
|
+
limit = 2
|
15
|
+
type = 'recommend'
|
16
|
+
context = 'ツイキャス 公式'
|
17
|
+
lang = 'ja'
|
18
|
+
api = TwicasStream::Search::SearchLiveMovies.new(limit, type, context, lang)
|
19
|
+
movies = api.response[:movies]
|
20
|
+
|
21
|
+
exit(0) unless api.response[:error].nil?
|
22
|
+
|
23
|
+
STDOUT.puts '--------------------------------'
|
24
|
+
movies.each{ |movie|
|
25
|
+
STDOUT.puts 'Movie ID is ' + movie[:movie][:id]
|
26
|
+
STDOUT.puts
|
27
|
+
|
28
|
+
STDOUT.puts '<Title>'
|
29
|
+
STDOUT.puts movie[:movie][:title].to_s + ' ~ ' + movie[:movie][:subtitle].to_s
|
30
|
+
STDOUT.puts
|
31
|
+
|
32
|
+
STDOUT.puts '<Tags>'
|
33
|
+
STDOUT.puts movie[:tags]
|
34
|
+
STDOUT.puts
|
35
|
+
|
36
|
+
STDOUT.puts 'Current View Count = ' + movie[:movie][:current_view_count].to_s
|
37
|
+
STDOUT.puts 'Total View Count = ' + movie[:movie][:total_view_count].to_s
|
38
|
+
|
39
|
+
STDOUT.puts '--------------------------------'
|
40
|
+
}
|
41
|
+
|
42
|
+
STDOUT.puts
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/twicas_stream')
|
6
|
+
|
7
|
+
TwicasStream.configure do |request_header|
|
8
|
+
#request_header.access_token = File.read(File.expand_path(File.dirname(__FILE__) + '/../config/access_token.txt'))
|
9
|
+
# => for developer
|
10
|
+
|
11
|
+
request_header.access_token = 'xxx'# put your access token here
|
12
|
+
end
|
13
|
+
|
14
|
+
words = 'ツイキャス 公式'
|
15
|
+
limit = 3
|
16
|
+
lang = 'ja'
|
17
|
+
api = TwicasStream::Search::SearchUsers.new(words, limit, lang)
|
18
|
+
users = api.response[:users]
|
19
|
+
|
20
|
+
exit(0) unless api.response[:error].nil?
|
21
|
+
|
22
|
+
STDOUT.puts
|
23
|
+
|
24
|
+
STDOUT.puts '--------------------------------'
|
25
|
+
users.each{ |user|
|
26
|
+
STDOUT.puts '<Name>'
|
27
|
+
STDOUT.puts user[:name]
|
28
|
+
STDOUT.puts
|
29
|
+
|
30
|
+
STDOUT.puts '<Screen ID>'
|
31
|
+
STDOUT.puts user[:screen_id]
|
32
|
+
STDOUT.puts
|
33
|
+
|
34
|
+
STDOUT.puts '<Profile>'
|
35
|
+
STDOUT.puts user[:profile]
|
36
|
+
STDOUT.puts
|
37
|
+
|
38
|
+
STDOUT.puts '--------------------------------'
|
39
|
+
}
|
40
|
+
|
41
|
+
STDOUT.puts
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#! /opt/local/bin/ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/twicas_stream')
|
6
|
+
|
7
|
+
TwicasStream.configure do |request_header|
|
8
|
+
#request_header.access_token = File.read(File.expand_path(File.dirname(__FILE__) + '/../config/access_token.txt'))
|
9
|
+
# => for developer
|
10
|
+
|
11
|
+
request_header.access_token = 'xxx'# put your access token here
|
12
|
+
end
|
13
|
+
|
14
|
+
api = TwicasStream::User::VerifyCredentials.new
|
15
|
+
app = api.response[:app]
|
16
|
+
user = api.response[:user]
|
17
|
+
|
18
|
+
unless api.response[:error].nil?
|
19
|
+
STDOUT.puts
|
20
|
+
|
21
|
+
STDOUT.puts '<Error Code>'
|
22
|
+
STDOUT.puts api.response[:error][:code]
|
23
|
+
STDOUT.puts
|
24
|
+
|
25
|
+
STDOUT.puts '<Error Message>'
|
26
|
+
STDOUT.puts api.response[:error][:message]
|
27
|
+
STDOUT.puts
|
28
|
+
|
29
|
+
exit(0)
|
30
|
+
end
|
31
|
+
|
32
|
+
STDOUT.puts
|
33
|
+
|
34
|
+
STDOUT.puts '<Client ID>'
|
35
|
+
STDOUT.puts app[:client_id]
|
36
|
+
STDOUT.puts
|
37
|
+
|
38
|
+
STDOUT.puts '<Application Name>'
|
39
|
+
STDOUT.puts app[:name]
|
40
|
+
STDOUT.puts
|
41
|
+
|
42
|
+
STDOUT.puts '<Name>'
|
43
|
+
STDOUT.puts user[:name]
|
44
|
+
STDOUT.puts
|
45
|
+
|
46
|
+
STDOUT.puts '<Screen ID>'
|
47
|
+
STDOUT.puts user[:screen_id]
|
48
|
+
STDOUT.puts
|
49
|
+
|
50
|
+
end
|