-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport.php
46 lines (31 loc) · 970 Bytes
/
export.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
<?php
require_once 'includes/core.php';
function getFavorites($type) {
$result = request('/favorite/getUserFavorites', 'GET', [
'type' => $type,
'limit' => PAGE_SIZE
]);
$favorites = $result[ $type ]['items'];
while (count($favorites) < $result[ $type ]['total']) {
$result = request('/favorite/getUserFavorites', 'GET', [
'type' => $type,
'limit' => PAGE_SIZE,
'offset' => $result[ $type ]['offset'] + PAGE_SIZE
]);
$favorites = array_merge($favorites, $result[ $type ]['items']);
}
return $favorites;
}
setup();
foreach (FAVORITE_TYPES as $type) {
print 'Exporting ' . $type . '... ';
$favorites = getFavorites($type);
if ($favorites) {
$file = EXPORT_PATH . '/' . $type . '.json';
file_put_contents($file, json_encode($favorites));
}
print 'OK!' . PHP_EOL;
}
print 'Done.' . PHP_EOL;
exit(0);
?>