forked from Moidea/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.php
36 lines (29 loc) · 793 Bytes
/
ajax.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
<?php
require dirname(__FILE__) . '/XiamiMusicAPI.php';
if(!isset($api)){
$api = new XiamiMusicAPI();
}
$type = $_GET['type'];
$id = $_GET['id'];
$page = isset($_GET['page']) ? ($_GET['page'])-1 : 0;
switch ($type) {
case 'songs' :
$data=json_decode($api->detail($id));
$data = $data ? $data->data->song : null;
break;
case 'album':
$data=json_decode($api->album($id));
$data = $data ? $data->data : null;
break;
case 'collect':
$data=json_decode($api->playlist($id));
$data = $data ? $data->data : null;
break;
case 'search':
$data=json_decode($api->search($id,5,$page));
$data = $data ? $data->data : null;
break;
}
header('Content-type: application/json; charset=UTF-8');
echo json_encode($data,JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
exit;