-
Notifications
You must be signed in to change notification settings - Fork 14
/
PixivAppAPI.php
executable file
·303 lines (286 loc) · 8.37 KB
/
PixivAppAPI.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?php
/**
* pixiv-api-php
* PixivApp API for PHP
*
* @package pixiv-api-php
* @author Kokororin
* @license MIT License
* @version 2.1
* @link https://github.com/kokororin/pixiv-api-php
*/
class PixivAppAPI extends PixivBase
{
/**
* @var string
*/
protected $api_prefix = 'https://app-api.pixiv.net';
/**
* @var string
*/
protected $api_filter = 'for_ios';
/**
* @var array
*/
protected $headers = array(
'Authorization' => 'Bearer WHDWCGnwWA2C8PRfQSdXJxjXp0G6ULRaRkkd6t5B6h8',
);
protected $noneAuthHeaders = array(
'User-Agent' => 'PixivIOSApp/6.7.1 (iOS 10.3.1; iPhone8,1)',
'App-OS' => 'ios',
'App-OS-Version' => '10.3.1',
'App-Version' => '6.9.0',
);
/**
* ユーザーの詳細
*
* @param string $user_id
* @return array
*/
public function user_detail($user_id)
{
return $this->fetch('/v1/user/detail', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'user_id' => $user_id,
'filter' => $this->api_filter,
),
));
}
/**
* ユーザーのイラスト
*
* @param string $user_id
* @param integer $page
* @param string $type
* @return array
*/
public function user_illusts($user_id, $page = 1, $type = 'illust')
{
return $this->fetch('/v1/user/illusts', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'user_id' => $user_id,
'type' => $type,
'offset' => ($page - 1) * 30,
'filter' => $this->api_filter,
),
));
}
/**
* 検索イラスト
*
* @param string $query
* @param integer $page
* @param string $search_target
* partial_match_for_tags
* exact_match_for_tags
* title_and_caption
* @param string $sort
* date_desc
* date_asc
* @param string $duration
* within_last_day
* within_last_week
* within_last_month
* @return array
*/
public function search_illust($word, $page = 1, $search_target = 'partial_match_for_tags', $sort = 'date_desc', $duration = null)
{
$body = array(
'word' => $word,
'search_target' => $search_target,
'sort' => $sort,
'offset' => ($page - 1) * 30,
'filter' => $this->api_filter,
);
if ($duration != null) {
$body['duration'] = $duration;
}
return $this->fetch('/v1/search/illust', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => $body,
));
}
/**
* ユーザーのマーク付きイラスト
*
* @param string $user_id
* @param string $restrict
* @return array
*/
public function user_bookmarks_illust($user_id, $restrict = 'public')
{
return $this->fetch('/v1/user/bookmarks/illust', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'user_id' => $user_id,
'restrict' => $restrict,
'filter' => $this->api_filter,
),
));
}
/**
* イラストの詳細
*
* @param string $illust_id
* @return array
*/
public function illust_detail($illust_id)
{
return $this->fetch('/v1/illust/detail', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'illust_id' => $illust_id,
),
));
}
/**
* イラストのコメント
*
* @param string $illust_id
* @param integer $page
* @param boolean $include_total_comments
* @return array
*/
public function illust_comments($illust_id, $page = 1, $include_total_comments = true)
{
return $this->fetch('/v1/illust/comments', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'illust_id' => $illust_id,
'offset' => ($page - 1) * 30,
'include_total_comments' => true,
),
));
}
/**
* 関連イラストリスト
*
* @param string $illust_id
* @param array $seed_illust_ids
* @return array
*/
public function illust_related($illust_id, $seed_illust_ids = null)
{
$body = array(
'illust_id' => $illust_id,
'filter' => $this->api_filter,
);
if (is_array($seed_illust_ids)) {
$body['seed_illust_ids[]'] = $seed_illust_ids;
}
return $this->fetch('/v2/illust/related', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => $body,
));
}
/**
* ランキングイラスト一覧
*
* @param string $mode
* day
* week
* month
* day_male
* day_female
* week_original
* week_rookie
* day_manga
* @param integer $page
* @param string $date YYYY-MM-DD
* @return [type]
*/
public function illust_ranking($mode = 'day', $page = 1, $date = null)
{
$body = array(
'mode' => $mode,
'offset' => ($page - 1) * 30,
'filter' => $this->api_filter,
);
if ($date != null) {
$body['date'] = $date;
}
return $this->fetch('/v1/illust/ranking', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => $body,
));
}
/**
* トレンドタグ
*
* @return array
*/
public function trending_tags_illust()
{
return $this->fetch('/v1/trending-tags/illust', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'filter' => $this->api_filter,
),
));
}
/**
* ユーザーのフォロー
* @param string $user_id
* @param string $restrict
* @param integer $page
* @return array
*/
public function user_following($user_id, $restrict = 'public', $page = 1)
{
return $this->fetch('/v1/user/following', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'user_id' => $user_id,
'restrict' => $restrict,
'offset' => ($page - 1) * 30,
),
));
}
/**
* ユーザーのフォロワー
* @param string $user_id
* @param integer $page
* @return array
*/
public function user_follower($user_id, $page = 1)
{
return $this->fetch('/v1/user/follower', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'user_id' => $user_id,
'filter' => $this->api_filter,
'offset' => ($page - 1) * 30,
),
));
}
/**
* ユーザーのマイピク
* @param string $user_id
* @param integer $page
* @return array
*/
public function user_mypixiv($user_id, $page = 1)
{
return $this->fetch('/v1/user/mypixiv', array(
'method' => 'get',
'headers' => array_merge($this->noneAuthHeaders, $this->headers),
'body' => array(
'user_id' => $user_id,
'offset' => ($page - 1) * 30,
),
));
}
}