├── LICENSE ├── README.md ├── api.php └── index.php /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # music163 API 2 | *** 3 | #### 高品质,快速度,简单易用的网易云音乐API 4 | 5 | [![versions](https://img.shields.io/badge/music163API-1.0.7-blue.svg)](https://www.icyuyan.net) 6 | [![platform](https://img.shields.io/badge/php-5.6-green.svg)]() 7 | [![platform](https://img.shields.io/badge/php-7.0-green.svg)]() 8 | 9 | ## **功能(**具体使用请参照本项目wiki**):** 10 | 11 | * 搜索 12 | * 歌曲详情 13 | * 获取某些歌曲下载链接 14 | * 歌手 15 | * 专辑 16 | * 歌词 17 | * mv 18 | * 歌手top50 19 | * 歌单 20 | * top排行榜 21 | *** 22 | 23 | ## 更新日志 24 | 2017年6月2日 v1.0.7 25 | * 增加获取用户歌单的api 26 | 27 | 2017年6月1日 v1.0.6 28 | * 彻底解决歌曲链接返回400错误的bug 29 | 30 | 2017年5月31日 v1.0.5 31 | * 继续修复获取歌曲链接返回400错误的bug ⊙﹏⊙‖∣° 真尴尬~~ 32 | 33 | 2017年5月31日 v1.0.4 34 | * 修复获取歌曲链接返回400错误的bug 35 | 36 | 2017年5月30日 V1.0.3 37 | * 新增top排行榜 38 | * 某些api 添加国内直接代理 不用http代理ip(额 有限制的 不可滥用 ==! 39 | * 修复某些api 返回为空的bug 40 | 41 | 2017年5月28日 v1.0.2 42 | * 新增歌词 mv 歌单 歌手top50 API 43 | 44 | 45 | 2017年5月27日 v1.0.1 46 | * 新增http代理 国外的空间或服务器可以使用 47 | * 新增新的搜索api 48 | * 新增歌手 api 49 | * 新增专辑 api 50 | 51 | ## **参考** 52 | 53 | * [网易云音乐常用API浅析](http://moonlib.com/606.html) 54 | 55 | *** 56 | 57 | ## License 58 | 59 | [MIT License](https://github.com/axhello/NeteaseCloudMusicApi/blob/master/LICENSE) -------------------------------------------------------------------------------- /api.php: -------------------------------------------------------------------------------- 1 | connecttimeout); 27 | curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); 28 | curl_setopt($curl, CURLOPT_REFERER, $this->refer); 29 | curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers); 30 | curl_setopt($curl, CURLOPT_ENCODING, 'application/json'); 31 | //代理设置 国外空间 或服务器请开启 32 | /* 33 | curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); // 代理认证模式 34 | curl_setopt($curl, CURLOPT_PROXY, '121.204.165.122'); // 代理服务器地址 35 | curl_setopt($curl, CURLOPT_PROXYPORT, 8118); // 代理服务器端口 36 | //curl_setopt($curl, CURLOPT_PROXYUSERPWD,""); // http代理认证帐号,username:password的格式 37 | curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // 使用http代理模式 38 | */ 39 | $result = curl_exec($curl); 40 | curl_close($curl); 41 | return $result; 42 | } 43 | protected function oldcurl($url){ 44 | $curl = curl_init(); 45 | curl_setopt($curl, CURLOPT_URL, $url); 46 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 47 | curl_setopt($curl, CURLOPT_BINARYTRANSFER, true); 48 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout); 49 | curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); 50 | curl_setopt($curl, CURLOPT_HTTPHEADER, $this->oldheaders); 51 | curl_setopt($curl, CURLOPT_REFERER, $this->refer); 52 | //代理设置 国外空间 或服务器请开启 53 | /* 54 | curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); // 代理认证模式 55 | curl_setopt($curl, CURLOPT_PROXY, '121.204.165.122'); // 代理服务器地址 56 | curl_setopt($curl, CURLOPT_PROXYPORT, 8118); // 代理服务器端口 57 | //curl_setopt($curl, CURLOPT_PROXYUSERPWD,""); // http代理认证帐号,username:password的格式 58 | curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // 使用http代理模式 59 | */ 60 | $result = curl_exec($curl); 61 | curl_close($curl); 62 | return $result; 63 | } 64 | //old搜索 o 65 | public function oldsearch($stype, $s, $limit){ 66 | $url = 'http://music.163.com/api/search/get/web?'; 67 | $data = "type=".$stype."&s=".$s."&limit=".$limit."&offset=0"; 68 | return $this->curl($url, $data); 69 | } 70 | //搜索 o 71 | public function search($stype, $s, $limit){ 72 | $url = 'http://music.163.com/api/cloudsearch/pc'; 73 | $data = "type=".$stype."&s=".$s."&limit=".$limit."&offset=0"; 74 | return $this->curl($url, $data); 75 | } 76 | //歌曲信息 o 77 | public function musicinfo($music_id){ 78 | $url = 'http://music.163.com/api/song/detail/?'; 79 | $data = "id=" . $music_id . "&ids=%5B" . $music_id . "%5D"; 80 | return $this->curl($url, $data); 81 | } 82 | //专辑信息 o 83 | public function musicalbum($album_id){ 84 | $url = "http://music.163.com/api/album/".$album_id."/"; 85 | return $this->oldcurl($url); 86 | } 87 | //歌手专辑信息 o 88 | public function artistalbums($artistalbums_id,$limit){ 89 | $url = "http://music.163.com/api/artist/albums/".$artistalbums_id."/?limit=".$limit; 90 | return $this->oldcurl($url); 91 | } 92 | //歌单信息 o 93 | //我的闽南语歌单721782642 94 | public function playlist($playlist_id){ 95 | $url = "http://music.163.com/api/playlist/detail?id=".$playlist_id; 96 | return $this->oldcurl($url); 97 | } 98 | //歌词信息 o 99 | //喜欢你==! 100 | //id=93920 101 | public function lyricinfo($music_id,$lv,$kv){ 102 | $url = "http://music.163.com/api/song/lyric?os=pc&id=".$music_id."&lv=".$lv."&kv=".$kv; 103 | return $this->oldcurl($url); 104 | } 105 | //mv链接 o 106 | //诛仙恋==! 107 | //id=5324450 108 | public function mvinfo($music_id,$mvtype){ 109 | $url = "http://music.163.com/api/mv/detail?id=".$music_id."&type=".$mvtype; 110 | return $this->oldcurl($url); 111 | } 112 | //歌手top50 o 113 | public function artisttop50($artist_id){ 114 | $url = "http://music.163.com/api/artist/".$artist_id."?ext=true&top=50&id=".$artist_id; 115 | return $this->oldcurl($url); 116 | } 117 | //download o 118 | public function olddownloadurl($music_id,$br){ 119 | $url = "http://music.163.com/api/song/enhance/download/url?br=".$br."&id=".$music_id; 120 | return $this->oldcurl($url); 121 | } 122 | //使用国内直接代理的api 不可滥用==! o 123 | public function downloadurl($music_id,$br){ 124 | $curl = new CCURL(); 125 | $url = "http://42.51.8.139:1111/music163/?type=musicurl&br=".$br."&id=".$music_id; 126 | return $curl->curl($url); 127 | } 128 | //用户歌单 o 129 | public function uplaylist($u_id,$limit){ 130 | $url = "http://music.163.com/api/user/playlist/?uid=".$u_id."&limit=".$limit."&offset=1"; 131 | return $this->oldcurl($url); 132 | } 133 | 134 | 135 | //http://music.163.com/api/user/playlist/?offset=1&limit=1&uid=137630579 136 | 137 | } 138 | class CCURL { 139 | protected $headers = ""; 140 | protected $refer = ""; 141 | protected $connecttimeout = 10; 142 | protected $timeout = 30; 143 | 144 | public function curl($url){ 145 | $curl = curl_init(); 146 | curl_setopt($curl, CURLOPT_URL, $url); 147 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 148 | curl_setopt($curl, CURLOPT_BINARYTRANSFER, true); 149 | curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout); 150 | curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout); 151 | curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers); 152 | curl_setopt($curl, CURLOPT_REFERER, $this->refer); 153 | //代理设置 国外空间 或服务器请开启 154 | /* 155 | curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); // 代理认证模式 156 | curl_setopt($curl, CURLOPT_PROXY, '121.204.165.122'); // 代理服务器地址 157 | curl_setopt($curl, CURLOPT_PROXYPORT, 8118); // 代理服务器端口 158 | //curl_setopt($curl, CURLOPT_PROXYUSERPWD,""); // http代理认证帐号,username:password的格式 159 | curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // 使用http代理模式 160 | */ 161 | $result = curl_exec($curl); 162 | curl_close($curl); 163 | return $result; 164 | } 165 | } 166 | 167 | 168 | //http://music.163.com/#/discover/toplist1 169 | ?> 170 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | search($stype,$s,$limit); 25 | echo $result; 26 | } 27 | //oldsearch 28 | else if ($_GET["type"] == "oldsearch") 29 | { 30 | $stype = $_GET["stype"]; 31 | $s = $_GET["s"]; 32 | $limit = $_GET["limit"]; 33 | if ($stype == NULL || $s == NULL || $limit == NULL) 34 | { 35 | echo "参数错误6"; 36 | exit(); 37 | } 38 | $result = $api->oldsearch($stype,$s,$limit); 39 | echo $result; 40 | } 41 | //单曲 42 | else if ($_GET["type"] == "song") 43 | { 44 | $id = $_GET["id"]; 45 | if ($id == NULL){ 46 | echo "参数错误4"; 47 | exit(); 48 | } 49 | $result = $api->musicinfo($id); 50 | echo $result; 51 | } 52 | 53 | //专辑 54 | else if ($_GET["type"] == "album") 55 | { 56 | $id = $_GET["id"]; 57 | if ($id == NULL){ 58 | echo "参数错误7"; 59 | exit(); 60 | } 61 | $result = $api->musicalbum($id); 62 | echo $result; 63 | } 64 | //歌手 65 | else if ($_GET["type"] == "artist") 66 | { 67 | $id = $_GET["id"]; 68 | $limit = $_GET["limit"]; 69 | if ($id == NULL || $limit == NULL){ 70 | echo "参数错误8"; 71 | exit(); 72 | } 73 | $result = $api->artistalbums($id, $limit); 74 | echo $result; 75 | } 76 | //歌单info 77 | else if ($_GET["type"] == "playlist") 78 | { 79 | $id = $_GET["id"]; 80 | if ($id == NULL){ 81 | echo "参数错误9"; 82 | exit(); 83 | } 84 | $result = $api->playlist($id); 85 | echo $result; 86 | } 87 | //歌词 88 | else if ($_GET["type"] == "lyric") 89 | { 90 | $id = $_GET["id"]; 91 | $lv = $_GET["lv"]; 92 | $kv = $_GET["kv"]; 93 | if ($id == NULL || $lv == NULL || $kv == NULL) 94 | { 95 | echo "参数错误10"; 96 | exit(); 97 | } 98 | $result = $api->lyricinfo($id,$lv,$kv); 99 | echo $result; 100 | } 101 | //歌手top50 102 | else if ($_GET["type"] == "atop50") 103 | { 104 | $id = $_GET["id"]; 105 | if ($id == NULL){ 106 | echo "参数错误11"; 107 | exit(); 108 | } 109 | $result = $api->artisttop50($id); 110 | echo $result; 111 | } 112 | 113 | //music url 114 | else if ($_GET["type"] == "musicurl") 115 | { 116 | $id = $_GET["id"]; 117 | $br = $_GET["br"]; 118 | if ($id == NULL || $br == NULL ){ 119 | echo "参数错误12"; 120 | exit(); 121 | } 122 | $result = $api->downloadurl($id,$br); 123 | echo $result; 124 | } 125 | //mvurl 126 | else if ($_GET["type"] == "mv") 127 | { 128 | $id = $_GET["id"]; 129 | $mvtype = $_GET["mvtype"]; 130 | if ($id == NULL || $mvtype == NULL ){ 131 | echo "参数错误13"; 132 | exit(); 133 | } 134 | $result = $api->mvinfo($id,$mvtype); 135 | echo $result; 136 | } 137 | //排行榜info 138 | else if ($_GET["type"] == "top") 139 | { 140 | $id = $_GET["id"]; 141 | if ($id == NULL){ 142 | echo "参数错误14"; 143 | exit(); 144 | } 145 | $result = $api->playlist($id); 146 | echo $result; 147 | } 148 | /* 149 | id: 71385702 //云音乐ACE音乐榜 150 | id: 19723756 // 云音乐飙升榜 o 151 | id: 2884035 // 网易原创歌曲榜 o 152 | id: 10520166 //云音乐电音榜 153 | id:71384707 //云音乐古典音乐榜 154 | id: 3778678 // 云音乐热歌榜 o 155 | id: 3779629 // 云音乐新歌榜 o 156 | id:71384707 //Beatport全球电子舞曲榜 157 | id:60131 //日本Oricon周榜 158 | id: 180106 //UK排行榜周榜 159 | id: 60198 //美国Billboard周榜 160 | id: 271135204 //法国 NRJ Vos Hits 周榜 161 | id: 11641012 //iTunes榜 162 | id:120001 //Hit FM Top榜 163 | id:21845217 //KTV唛榜 164 | id:1899724 //中国嘻哈榜 165 | id: 4395559 // 华语金曲榜 166 | id: 64016 // 中国TOP排行榜(内地榜) 167 | id: 112504 // 中国TOP排行榜(港台榜) 168 | */ 169 | //用户歌单 170 | else if ($_GET["type"] == "uplaylist") 171 | { 172 | $uid = $_GET["uid"]; 173 | $limit = $_GET["limit"]; 174 | if ($uid == NULL || $limit == NULL) 175 | { 176 | echo "参数错误15"; 177 | exit(); 178 | } 179 | $result = $api->uplaylist($uid,$limit); 180 | echo $result; 181 | } 182 | 183 | else 184 | { 185 | echo "参数错误2"; 186 | exit(); 187 | } 188 | } 189 | else 190 | { 191 | echo "参数错误1"; 192 | exit(); 193 | } 194 | 195 | 196 | ?> --------------------------------------------------------------------------------