Skip to content

Commit 6cfd7d4

Browse files
author
kilingzhang
committed
NeteaseCloudMusicApi
截至目前位置所有不需要登陆的接口
1 parent 8d0601f commit 6cfd7d4

25 files changed

+3270
-33
lines changed

composer.json

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
{
2-
"name": "kilingzhang/netease-cloud-music-api",
3-
"authors": [
4-
{
5-
"name": "kilingzhang",
6-
"email": "slight@kilingzhang.com"
7-
}
8-
],
9-
"description": "网易云音乐 PHP 版 API",
10-
"keywords": [
11-
"网易云音乐",
12-
"网易云",
13-
"音乐",
14-
"网易云音乐PHP"
15-
],
16-
"require": {
17-
18-
},
19-
"license": "MIT"
2+
"name": "kilingzhang/netease-cloud-music-api",
3+
"type": "library",
4+
"authors": [
5+
{
6+
"name": "kilingzhang",
7+
"email": "slight@kilingzhang.com",
8+
"homepage": "http://www.kilingzhang.com/",
9+
"role": "Developer"
10+
}
11+
],
12+
"homepage": "http://github.com/kilingzhang/neteaseCloudMusicApi",
13+
"require": {
14+
"caoym/phpboot": "^2.0.7"
15+
},
16+
"repositories": {
17+
"packagist": {
18+
"type": "composer",
19+
"url": "https://packagist.phpcomposer.com"
20+
}
21+
},
22+
"description": "网易云音乐 PHP 版 API",
23+
"keywords": [
24+
"网易云音乐",
25+
"网易云",
26+
"音乐",
27+
"网易云音乐PHP"
28+
],
29+
"license": "MIT"
2030
}

src/NeteaseCloudMusicApiSdk/Album.php

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Kilingzhang <slight@kilingzhang.com>
5+
* Date: 2017/8/19
6+
* Time: 22:11
7+
*/
8+
9+
namespace NeteaseCloudMusicApiSdk;
10+
use PhpBoot\Application;
11+
use PhpBoot\DI\Traits\EnableDIAnnotations;
12+
use Utils\Request;
13+
use Utils\Snoopy;
14+
15+
class Album
16+
{
17+
18+
use EnableDIAnnotations;
19+
20+
/**
21+
*
22+
* 获取专辑内容
23+
* 说明:调用此接口,传入专辑 id,可获得专辑内容
24+
*
25+
* 必选参数:
26+
* id: 专辑 id
27+
*
28+
* 接口地址:
29+
* /album
30+
*
31+
* 调用例子:
32+
* /album?id=32311
33+
* @route GET /album
34+
* @param string $id
35+
* @return string json
36+
*/
37+
public function album($id)
38+
{
39+
$Request = new Request();
40+
$data = array(
41+
'csrf_token' => '',
42+
);
43+
$response = $Request->createWebAPIRequest(
44+
"http://music.163.com",
45+
"/weapi/v1/album/{$id}",
46+
'POST',
47+
$data
48+
);
49+
return \GuzzleHttp\json_decode($response, true);
50+
}
51+
52+
53+
/**
54+
*
55+
* 获取歌手描述
56+
* 说明:调用此接口,传入歌手 id,可获得歌手描述
57+
*
58+
* 必选参数:
59+
* id: 歌手 id
60+
*
61+
* 接口地址:
62+
* /artist/desc
63+
*
64+
* 调用例子:
65+
* /artist/desc?id=6452 (周杰伦)
66+
*
67+
* @route GET /artist/desc
68+
* @param int $id
69+
* @return string json
70+
*/
71+
public function desc($id)
72+
{
73+
$Request = new Request();
74+
$data = array(
75+
'id'=>$id,
76+
'csrf_token' => '',
77+
);
78+
$response = $Request->createWebAPIRequest(
79+
"http://music.163.com",
80+
"/weapi/artist/introduction",
81+
'POST',
82+
$data
83+
);
84+
return \GuzzleHttp\json_decode($response, true);
85+
}
86+
87+
}

src/NeteaseCloudMusicApiSdk/App.php

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Kilingzhang <slight@kilingzhang.com>
5+
* Date: 2017/8/19
6+
* Time: 19:22
7+
*/
8+
9+
namespace NeteaseCloudMusicApiSdk;
10+
11+
use PhpBoot\Application;
12+
use PhpBoot\DI\Traits\EnableDIAnnotations;
13+
use Utils\Request;
14+
use Utils\Snoopy;
15+
16+
class Artists
17+
{
18+
19+
use EnableDIAnnotations;
20+
21+
/**
22+
*
23+
* 获取歌手单曲
24+
* 说明:调用此接口,传入歌手 id,可获得歌手单曲
25+
*
26+
* 必选参数:
27+
* id: 歌手 id,可由搜索接口获得
28+
*
29+
* 接口地址:
30+
* /artists
31+
*
32+
* 调用例子:
33+
* /artists?id=6452
34+
* @route GET /artists
35+
* @param string $id
36+
* @param int $offset
37+
* @param int $limit
38+
* @return string json
39+
*/
40+
public function artists($id, $offset = 0, $limit = 50)
41+
{
42+
$Request = new Request();
43+
$data = array(
44+
45+
'csrf_token' => '',
46+
);
47+
$response = $Request->createWebAPIRequest(
48+
"http://music.163.com",
49+
"/weapi/v1/artist/{$id}?offset={$offset}&limit={$limit}",
50+
'POST',
51+
$data
52+
);
53+
return \GuzzleHttp\json_decode($response, true);
54+
}
55+
56+
57+
/**
58+
*
59+
* 获取歌手 mv
60+
* 说明:调用此接口,传入歌手 id,可获得歌手 mv 信息,具体 mv 播放地址可调用/mv传入此接口获得的mvid 来拿到,如: /artist/mv?id=6452,/mv?mvid=5461064
61+
*
62+
* 必选参数:
63+
* id: 歌手 id,可由搜索接口获得
64+
*
65+
* 接口地址:
66+
* /artist/mv
67+
*
68+
* 调用例子:
69+
* /artist/mv?id=6452
70+
* @route GET /artist/mv
71+
* @param string $id
72+
* @param boolean $total
73+
* @param int $limit
74+
* @param int $offset
75+
* @return string json
76+
*/
77+
public function mv($id,$total = true , $offset = 0, $limit = 50)
78+
{
79+
$Request = new Request();
80+
$data = array(
81+
'artistId'=>$id,
82+
'total'=>$total,
83+
'offset'=>$offset,
84+
'limit'=>$limit,
85+
'csrf_token' => '',
86+
);
87+
$response = $Request->createWebAPIRequest(
88+
"http://music.163.com",
89+
"/weapi/artist/mvs",
90+
'POST',
91+
$data
92+
);
93+
return \GuzzleHttp\json_decode($response, true);
94+
}
95+
96+
97+
/**
98+
*
99+
* 获取歌手专辑
100+
* 说明:调用此接口,传入歌手 id,可获得歌手专辑内容
101+
*
102+
* 必选参数:
103+
* id: 歌手 id
104+
*
105+
* 可选参数:
106+
* limit: 取出数量,默认为50
107+
*
108+
* offset: 偏移数量,用于分页,如:(页数-1)*50, 其中 50 为 limit 的值,默认为0
109+
*
110+
* 接口地址:
111+
* /artist/album
112+
*
113+
* 调用例子:
114+
* /artist/album?id=6452&limit=30 (周杰伦)
115+
*
116+
* @route GET /artist/album
117+
* @param string $id
118+
* @param boolean $total
119+
* @param int $limit
120+
* @param int $offset
121+
* @return string json
122+
*/
123+
public function album($id,$total = true , $offset = 0, $limit = 50)
124+
{
125+
$Request = new Request();
126+
$data = array(
127+
'total'=>$total,
128+
'offset'=>$offset,
129+
'limit'=>$limit,
130+
'csrf_token' => '',
131+
);
132+
$response = $Request->createWebAPIRequest(
133+
"http://music.163.com",
134+
"/weapi/artist/albums/{$id}",
135+
'POST',
136+
$data
137+
);
138+
return \GuzzleHttp\json_decode($response, true);
139+
}
140+
141+
142+
143+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Kilingzhang <slight@kilingzhang.com>
5+
* Date: 2017/8/19
6+
* Time: 19:22
7+
*/
8+
9+
namespace NeteaseCloudMusicApiSdk;
10+
11+
use PhpBoot\Application;
12+
use PhpBoot\DI\Traits\EnableDIAnnotations;
13+
use Utils\Request;
14+
use Utils\Snoopy;
15+
16+
class Banner
17+
{
18+
19+
use EnableDIAnnotations;
20+
21+
/**
22+
* @route GET /banner
23+
* @return string json
24+
*/
25+
public function banner()
26+
{
27+
$Request = new Request();
28+
$data = array(
29+
30+
'csrf_token' => '',
31+
);
32+
$response = $Request->createWebAPIRequest(
33+
"http://music.163.com",
34+
"/weapi/v2/banner/get",
35+
'POST',
36+
$data
37+
);
38+
return \GuzzleHttp\json_decode($response, true);
39+
}
40+
41+
42+
}

0 commit comments

Comments
 (0)