网易云音乐常用API浅析

xiaoxiao2021-02-28  10

话不多说

PC客户端抓包而来

0.说明

关于头部信息

Cookie: os=pc; deviceId=B55AC773505E5606F9D355A1A15553CE78B89FC7D8CB8A157B84; osver=Microsoft-Windows-8-Professional-build-9200-64bit; appver=1.5.0.75771; usertrack=ezq0alR0yqJMJC0dr9tEAg==; MUSIC_A=088a57b553bd8cef58487f9d01ae User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.138 Safari/537.36\r\n <div class="crayon-main" style="position: relative; z-index: 1; overflow: hidden;"> <table class="crayon-table"> <tbody><tr class="crayon-row"> <td class="crayon-nums " data-settings="show"> <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-5aa39c0c2ed27407466969-1" style="height: 43px;">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed27407466969-2" style="height: 29px;">2</div></div> </td> <td class="crayon-code"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;"><div class="crayon-line" id="crayon-5aa39c0c2ed27407466969-1">Cookie: os=pc; deviceId=B55AC773505E5606F9D355A1A15553CE78B89FC7D8CB8A157B84; osver=Microsoft-Windows-8-Professional-build-9200-64bit; appver=1.5.0.75771; usertrack=ezq0alR0yqJMJC0dr9tEAg==; MUSIC_A=088a57b553bd8cef58487f9d01ae</div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed27407466969-2">User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.138 Safari/537.36\r\n</div></div></td> </tr> </tbody></table> </div> </div>

上面是抓到的信息,其中必要的只有cookie中的appver。而且如果要调用api,必须加上Referer,只要是music.163.com的就可以

Cookie: appver=1.5.0.75771; Referer: http://music.163.com/ 1 2 Cookie: appver=1.5.0.75771; Referer: http://music.163.com/

以上两条即可

返回的格式均为json

 

1.搜索

抓取到的信息如下

Full request URI:http://music.163.com/api/search/pc Key: hlpretag Value: <span class=”s-fc2”> Key: hlposttag Value: </span> Key: s Value: \345\226\234\346\254\242\344\275\240 Key: offset Value: 0 Key: total Value: true Key: limit Value: 100 Key: type Value: 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Full request URI:http://music.163.com/api/search/pc Key: hlpretag Value: <span class=”s-fc2”> Key: hlposttag Value: </span> Key: s Value: \345\226\234\346\254\242\344\275\240 Key: offset Value: 0 Key: total Value: true Key: limit Value: 100 Key: type Value: 1

URL:

POST http://music.163.com/api/search/pc

必要参数:

s:搜索的内容

offset:偏移量(分页用)

limit:获取的数量

type:搜索的类型

歌曲 1

专辑 10

歌手 100

歌单 1000

用户 1002

mv 1004

歌词 1006

主播电台 1009

 

2.歌曲信息

Full request URI: http://music.163.com/api/song/detail/?id=28377211&ids=[28377211] 1 Full request URI: http://music.163.com/api/song/detail/?id=28377211&ids=[28377211]

URL:

GET  http://music.163.com/api/song/detail/

必要参数:

id:歌曲ID

ids:不知道干什么用的,用[]括起来的歌曲ID

 

3.歌手专辑

Full request URI: http://music.163.com/api/artist/albums/166009?id=166009&offset=0&total=true&limit=5 1 Full request URI: http://music.163.com/api/artist/albums/166009?id=166009&offset=0&total=true&limit=5

URL:

GET http://music.163.com/api/artist/albums/歌手ID

必要参数:

limit:获取的数量(不知道为什么这个必须加上)

 

4.专辑信息

Full request URI: http://music.163.com/api/album/2457012?ext=true&id=2457012&offset=0&total=true&limit=10 1 Full request URI: http://music.163.com/api/album/2457012?ext=true&id=2457012&offset=0&total=true&limit=10

URL:

GET http://music.163.com/api/album/专辑ID

 

5.歌单

Full request URI: http://music.163.com/api/playlist/detail?id=37880978&updateTime=-1 1 Full request URI: http://music.163.com/api/playlist/detail?id=37880978&updateTime=-1

URL:

GET http://music.163.com/api/playlist/detail

必要参数:

id:歌单ID

 

6.歌词

Full request URI: http://music.163.com/api/song/lyric?os=pc&id=93920&lv=-1&kv=-1&tv=-1 1 Full request URI: http://music.163.com/api/song/lyric?os=pc&id=93920&lv=-1&kv=-1&tv=-1

URL:

GET http://music.163.com/api/song/lyric

必要参数:

id:歌曲ID

lv:值为-1,我猜测应该是判断是否搜索lyric格式

kv:值为-1,这个值貌似并不影响结果,意义不明

tv:值为-1,是否搜索tlyric格式

 

7.MV

Full request URI: http://music.163.com/api/mv/detail?id=319104&type=mp4 1 Full request URI: http://music.163.com/api/mv/detail?id=319104&type=mp4

URL:

GET http://music.163.com/api/mv/detail

必要参数:

id:mvid

type:值为mp4,视频格式,不清楚还有没有别的格式

 

 

PHP版使用示例

PHP <?php /** * Created by PhpStorm. * User: Moon * Date: 2014/11/26 0026 * Time: 2:06 */ function curl_get( url)$refer=http://music.163.com/;$header[]=Cookie:.appver=1.5.0.75771;;$ch=curlinit();curlsetopt($ch,CURLOPTURL,$url);curlsetopt($ch,CURLOPTHTTPHEADER,$header);curlsetopt($ch,CURLOPTRETURNTRANSFER,true);curlsetopt($ch,CURLOPTBINARYTRANSFER,true);curlsetopt($ch,CURLOPTREFERER,$refer);$output=curlexec($ch);curlclose($ch);return$output;functionmusicsearch( u r l ) $ r e f e r = “ h t t p : / / m u s i c .163 . c o m / ” ; $ h e a d e r [ ] = “ C o o k i e : ” . “ a p p v e r = 1.5.0.75771 ; ” ; $ c h = c u r l i n i t ( ) ; c u r l s e t o p t ( $ c h , C U R L O P T U R L , $ u r l ) ; c u r l s e t o p t ( $ c h , C U R L O P T H T T P H E A D E R , $ h e a d e r ) ; c u r l s e t o p t ( $ c h , C U R L O P T R E T U R N T R A N S F E R , t r u e ) ; c u r l s e t o p t ( $ c h , C U R L O P T B I N A R Y T R A N S F E R , t r u e ) ; c u r l s e t o p t ( $ c h , C U R L O P T R E F E R E R , $ r e f e r ) ; $ o u t p u t = c u r l e x e c ( $ c h ) ; c u r l c l o s e ( $ c h ) ; r e t u r n $ o u t p u t ; f u n c t i o n m u s i c s e a r c h ( word, type){    $url = “http://music.163.com/api/search/pc”;    $post_data = array(        ‘s’ => $word,        ‘offset’ => ‘0’,        ‘limit’ => ‘20’,        ‘type’ => $type,    );    $referrer = “http://music.163.com/”;    $URL_Info = parse_url($url);    $values = [];    $result = ”;    $request = ”;    foreach ($post_data as $key => $value) {        $values[] = "$key=” . urlencode($value);    }    $data_string = implode("&", $values);    if (!isset($URL_Info[“port”])) {        $URL_Info[“port”] = 80;    }    $request .= "POST " . $URL_Info[“path”] . ” HTTP/1.1\n”;    $request .= "Host: " . $URL_Info[“host”] . “\n”;    $request .= "Referer: $referrer\n”;    $request .= “Content-type: application/x-www-form-urlencoded\n”;    $request .= "Content-length: " . strlen($data_string) . “\n”;    $request .= “Connection: close\n”;    $request .= “Cookie: ” . “appver=1.5.0.75771;\n”;    $request .= “\n”;    $request .= $data_string . “\n”;    $fp = fsockopen($URL_Info[“host”], $URL_Info[“port”]);    fputs($fp, $request);    $i = 1;    while (!feof($fp)) {        if ($i >= 15) {            $result .= fgets($fp);        } else {            fgets($fp);            $i++;        }    }    fclose($fp);    return $result;}function get_music_info( type){    $url = “http://music.163.com/api/search/pc”;    $post_data = array(        ‘s’ => $word,        ‘offset’ => ‘0’,        ‘limit’ => ‘20’,        ‘type’ => $type,    );    $referrer = “http://music.163.com/”;    $URL_Info = parse_url($url);    $values = [];    $result = ”;    $request = ”;    foreach ($post_data as $key => $value) {        $values[] = "$key=” . urlencode($value);    }    $data_string = implode("&", $values);    if (!isset($URL_Info[“port”])) {        $URL_Info[“port”] = 80;    }    $request .= "POST " . $URL_Info[“path”] . ” HTTP/1.1\n”;    $request .= "Host: " . $URL_Info[“host”] . “\n”;    $request .= "Referer: $referrer\n”;    $request .= “Content-type: application/x-www-form-urlencoded\n”;    $request .= "Content-length: " . strlen($data_string) . “\n”;    $request .= “Connection: close\n”;    $request .= “Cookie: ” . “appver=1.5.0.75771;\n”;    $request .= “\n”;    $request .= $data_string . “\n”;    $fp = fsockopen($URL_Info[“host”], $URL_Info[“port”]);    fputs($fp, $request);    $i = 1;    while (!feof($fp)) {        if ($i >= 15) {            $result .= fgets($fp);        } else {            fgets($fp);            $i++;        }    }    fclose($fp);    return $result;}function get_music_info( music_id) { url="http://music.163.com/api/song/detail/?id=". u r l =" h t t p : / / m u s i c .163 . c o m / a p i / s o n g / d e t a i l / ? i d =" . music_id . “&ids=[” . musicid.returncurlget( m u s i c i d . “ r e t u r n c u r l g e t ( url); } function get_artist_album( artistid, a r t i s t i d , limit) { url="http://music.163.com/api/artist/albums/". u r l =" h t t p : / / m u s i c .163 . c o m / a p i / a r t i s t / a l b u m s / " . artist_id . “?limit=” . limit;returncurlget( l i m i t ; r e t u r n c u r l g e t ( url); } function get_album_info( albumid)$url="http://music.163.com/api/album/".$albumid;returncurlget($url);functiongetplaylistinfo( a l b u m i d ) $ u r l =" h t t p : / / m u s i c .163 . c o m / a p i / a l b u m / " . $ a l b u m i d ; r e t u r n c u r l g e t ( $ u r l ) ; f u n c t i o n g e t p l a y l i s t i n f o ( playlist_id) { url="http://music.163.com/api/playlist/detail?id=". u r l =" h t t p : / / m u s i c .163 . c o m / a p i / p l a y l i s t / d e t a i l ? i d =" . playlist_id; return curl_get( url);}function get_music_lyric( url);}function get_music_lyric( music_id) { url = "http://music.163.com/api/song/lyric?os=pc&id=" . url = "http://music.163.com/api/song/lyric?os=pc&id=" . music_id . “&lv=-1&kv=-1&tv=-1”; return curl_get( url);}function get_mv_info(){ url);}function get_mv_info(){ url = “http://music.163.com/api/mv/detail?id=319104&type=mp4”; return curl_get($url); } #echo music_search(“Moon Without The Stars”, “1”); #get_music_info(“28949444”); #echo get_artist_album(“166009”, “5”); #echo get_album_info(“3021064”); #echo get_playlist_info(“22320356”); #echo get_music_lyric(“29567020”);

echo get_mv_info();

<div class="crayon-main" style="position: relative; z-index: 1; overflow: hidden;" data-find="_6"> <table class="crayon-table" data-find="_5"> <tbody data-find="_4"><tr class="crayon-row" data-find="_3"> <td class="crayon-nums " data-settings="show"> <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;"><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-1">1</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-2">2</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-3">3</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-4">4</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-5">5</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-6">6</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-7">7</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-8">8</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-9">9</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-10">10</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-11">11</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-12">12</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-13">13</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-14">14</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-15">15</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-16">16</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-17">17</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-18">18</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-19">19</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-20">20</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-21">21</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-22">22</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-23">23</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-24">24</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-25">25</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-26">26</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-27">27</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-28">28</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-29">29</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-30">30</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-31">31</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-32">32</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-33">33</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-34">34</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-35">35</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-36">36</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-37">37</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-38">38</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-39">39</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-40">40</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-41">41</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-42">42</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-43">43</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-44">44</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-45">45</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-46">46</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-47">47</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-48">48</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-49">49</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-50">50</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-51">51</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-52">52</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-53">53</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-54">54</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-55">55</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-56">56</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-57">57</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-58">58</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-59">59</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-60">60</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-61">61</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-62">62</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-63">63</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-64">64</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-65">65</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-66">66</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-67">67</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-68">68</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-69">69</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-70">70</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-71">71</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-72">72</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-73">73</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-74">74</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-75">75</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-76">76</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-77">77</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-78">78</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-79">79</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-80">80</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-81">81</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-82">82</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-83">83</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-84">84</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-85">85</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-86">86</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-87">87</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-88">88</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-89">89</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-90">90</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-91">91</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-92">92</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-93">93</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-94">94</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-95">95</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-96">96</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-97">97</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-98">98</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-99">99</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-100">100</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-101">101</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-102">102</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-103">103</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-104">104</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-105">105</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-106">106</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-107">107</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-108">108</div><div class="crayon-num" data-line="crayon-5aa39c0c2ed42507386183-109">109</div><div class="crayon-num crayon-striped-num" data-line="crayon-5aa39c0c2ed42507386183-110">110</div></div> </td> <td class="crayon-code" data-find="_2"><div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;" data-find="_1"><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-1"><span class="crayon-ta"><?php</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-2"><span class="crayon-c">/**</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-3"><span class="crayon-c"> * Created by PhpStorm.</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-4"><span class="crayon-c"> * User: Moon</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-5"><span class="crayon-c"> * Date: 2014/11/26 0026</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-6"><span class="crayon-c"> * Time: 2:06</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-7"><span class="crayon-c"> */</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-8"><span class="crayon-t">function</span><span class="crayon-h"> </span><span class="crayon-e">curl_get</span><span class="crayon-sy">(</span><span class="crayon-v">$url</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-9"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-10"><span class="crayon-h">    </span><span class="crayon-v">$refer</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-11"><span class="crayon-h">    </span><span class="crayon-v">$header</span><span class="crayon-sy">[</span><span class="crayon-sy">]</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"Cookie: "</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"appver=1.5.0.75771;"</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-12"><span class="crayon-h">    </span><span class="crayon-v">$ch</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">curl_init</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-13"><span class="crayon-h">    </span><span class="crayon-e">curl_setopt</span><span class="crayon-sy">(</span><span class="crayon-v">$ch</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">CURLOPT_URL</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">$url</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-14"><span class="crayon-h">    </span><span class="crayon-e">curl_setopt</span><span class="crayon-sy">(</span><span class="crayon-v">$ch</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">CURLOPT_HTTPHEADER</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">$header</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-15"><span class="crayon-h">    </span><span class="crayon-e">curl_setopt</span><span class="crayon-sy">(</span><span class="crayon-v">$ch</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">CURLOPT_RETURNTRANSFER</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-t">true</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-16"><span class="crayon-h">    </span><span class="crayon-e">curl_setopt</span><span class="crayon-sy">(</span><span class="crayon-v">$ch</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">CURLOPT_BINARYTRANSFER</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-t">true</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-17"><span class="crayon-h">    </span><span class="crayon-e">curl_setopt</span><span class="crayon-sy">(</span><span class="crayon-v">$ch</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-cn">CURLOPT_REFERER</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">$refer</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-18"><span class="crayon-h">    </span><span class="crayon-v">$output</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">curl_exec</span><span class="crayon-sy">(</span><span class="crayon-v">$ch</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-19"><span class="crayon-h">    </span><span class="crayon-e">curl_close</span><span class="crayon-sy">(</span><span class="crayon-v">$ch</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-20"><span class="crayon-h">    </span><span class="crayon-k ">return</span><span class="crayon-h"> </span><span class="crayon-v">$output</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-21"><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-22"> </div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-23"><span class="crayon-t">function</span><span class="crayon-h"> </span><span class="crayon-e">music_search</span><span class="crayon-sy">(</span><span class="crayon-v">$word</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">$type</span><span class="crayon-sy">)</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-24"><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-25"><span class="crayon-h">    </span><span class="crayon-v">$url</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/api/search/pc"</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-26"><span class="crayon-h">    </span><span class="crayon-v">$post_data</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-t">array</span><span class="crayon-sy">(</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-27"><span class="crayon-h">        </span><span class="crayon-s">'s'</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-o">></span><span class="crayon-h"> </span><span class="crayon-v">$word</span><span class="crayon-sy">,</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-28"><span class="crayon-h">        </span><span class="crayon-s">'offset'</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-o">></span><span class="crayon-h"> </span><span class="crayon-s">'0'</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-29"><span class="crayon-h">        </span><span class="crayon-s">'limit'</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-o">></span><span class="crayon-h"> </span><span class="crayon-s">'20'</span><span class="crayon-sy">,</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-30"><span class="crayon-h">        </span><span class="crayon-s">'type'</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-o">></span><span class="crayon-h"> </span><span class="crayon-v">$type</span><span class="crayon-sy">,</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-31"><span class="crayon-h">    </span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-32"><span class="crayon-h">    </span><span class="crayon-v">$referrer</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-33"><span class="crayon-h">    </span><span class="crayon-v">$URL_Info</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">parse_url</span><span class="crayon-sy">(</span><span class="crayon-v">$url</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-34"><span class="crayon-h">    </span><span class="crayon-v">$values</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-sy">[</span><span class="crayon-sy">]</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-35"><span class="crayon-h">    </span><span class="crayon-v">$result</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">''</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-36"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">''</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-37"><span class="crayon-h">    </span><span class="crayon-st">foreach</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-v">$post_data</span><span class="crayon-h"> </span><span class="crayon-st">as</span><span class="crayon-h"> </span><span class="crayon-v">$key</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-o">></span><span class="crayon-h"> </span><span class="crayon-v">$value</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-38"><span class="crayon-h">        </span><span class="crayon-v">$values</span><span class="crayon-sy">[</span><span class="crayon-sy">]</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"$key="</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-e">urlencode</span><span class="crayon-sy">(</span><span class="crayon-v">$value</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-39"><span class="crayon-h">    </span><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-40"><span class="crayon-h">    </span><span class="crayon-v">$data_string</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">implode</span><span class="crayon-sy">(</span><span class="crayon-s">"&"</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">$values</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-41"><span class="crayon-h">    </span><span class="crayon-st">if</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-o">!</span><span class="crayon-k ">isset</span><span class="crayon-sy">(</span><span class="crayon-v">$URL_Info</span><span class="crayon-sy">[</span><span class="crayon-s">"port"</span><span class="crayon-sy">]</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-42"><span class="crayon-h">        </span><span class="crayon-v">$URL_Info</span><span class="crayon-sy">[</span><span class="crayon-s">"port"</span><span class="crayon-sy">]</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-cn">80</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-43"><span class="crayon-h">    </span><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-44"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"POST "</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$URL_Info</span><span class="crayon-sy">[</span><span class="crayon-s">"path"</span><span class="crayon-sy">]</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">" HTTP/1.1\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-45"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"Host: "</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$URL_Info</span><span class="crayon-sy">[</span><span class="crayon-s">"host"</span><span class="crayon-sy">]</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-46"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"Referer: $referrer\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-47"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"Content-type: application/x-www-form-urlencoded\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-48"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"Content-length: "</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-e">strlen</span><span class="crayon-sy">(</span><span class="crayon-v">$data_string</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-49"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"Connection: close\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-50"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"Cookie: "</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"appver=1.5.0.75771;\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-51"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-52"><span class="crayon-h">    </span><span class="crayon-v">$request</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-v">$data_string</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"\n"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-53"><span class="crayon-h">    </span><span class="crayon-v">$fp</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">fsockopen</span><span class="crayon-sy">(</span><span class="crayon-v">$URL_Info</span><span class="crayon-sy">[</span><span class="crayon-s">"host"</span><span class="crayon-sy">]</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">$URL_Info</span><span class="crayon-sy">[</span><span class="crayon-s">"port"</span><span class="crayon-sy">]</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-54"><span class="crayon-h">    </span><span class="crayon-e">fputs</span><span class="crayon-sy">(</span><span class="crayon-v">$fp</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">$request</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-55"><span class="crayon-h">    </span><span class="crayon-v">$i</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-cn">1</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-56"><span class="crayon-h">    </span><span class="crayon-st">while</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-o">!</span><span class="crayon-e">feof</span><span class="crayon-sy">(</span><span class="crayon-v">$fp</span><span class="crayon-sy">)</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-57"><span class="crayon-h">        </span><span class="crayon-st">if</span><span class="crayon-h"> </span><span class="crayon-sy">(</span><span class="crayon-v">$i</span><span class="crayon-h"> </span><span class="crayon-o">>=</span><span class="crayon-h"> </span><span class="crayon-cn">15</span><span class="crayon-sy">)</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-58"><span class="crayon-h">            </span><span class="crayon-v">$result</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-e">fgets</span><span class="crayon-sy">(</span><span class="crayon-v">$fp</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-59"><span class="crayon-h">        </span><span class="crayon-sy">}</span><span class="crayon-h"> </span><span class="crayon-st">else</span><span class="crayon-h"> </span><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-60"><span class="crayon-h">            </span><span class="crayon-e">fgets</span><span class="crayon-sy">(</span><span class="crayon-v">$fp</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-61"><span class="crayon-h">            </span><span class="crayon-v">$i</span><span class="crayon-o">++</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-62"><span class="crayon-h">        </span><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-63"><span class="crayon-h">    </span><span class="crayon-sy">}</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-64"><span class="crayon-h">    </span><span class="crayon-e">fclose</span><span class="crayon-sy">(</span><span class="crayon-v">$fp</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-65"><span class="crayon-h">    </span><span class="crayon-k ">return</span><span class="crayon-h"> </span><span class="crayon-v">$result</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-66"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-67"> </div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-68"><span class="crayon-t">function</span><span class="crayon-h"> </span><span class="crayon-e">get_music_info</span><span class="crayon-sy">(</span><span class="crayon-v">$music_id</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-69"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-70"><span class="crayon-h">    </span><span class="crayon-v">$url</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/api/song/detail/?id="</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$music_id</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"&ids=["</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$music_id</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"]"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-71"><span class="crayon-h">    </span><span class="crayon-k ">return</span><span class="crayon-h"> </span><span class="crayon-e">curl_get</span><span class="crayon-sy">(</span><span class="crayon-v">$url</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-72"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-73"> </div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-74"><span class="crayon-t">function</span><span class="crayon-h"> </span><span class="crayon-e">get_artist_album</span><span class="crayon-sy">(</span><span class="crayon-v">$artist_id</span><span class="crayon-sy">,</span><span class="crayon-h"> </span><span class="crayon-v">$limit</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-75"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-76"><span class="crayon-h">    </span><span class="crayon-v">$url</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/api/artist/albums/"</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$artist_id</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"?limit="</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$limit</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-77"><span class="crayon-h">    </span><span class="crayon-k ">return</span><span class="crayon-h"> </span><span class="crayon-e">curl_get</span><span class="crayon-sy">(</span><span class="crayon-v">$url</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-78"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-79"> </div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-80"><span class="crayon-t">function</span><span class="crayon-h"> </span><span class="crayon-e">get_album_info</span><span class="crayon-sy">(</span><span class="crayon-v">$album_id</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-81"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-82"><span class="crayon-h">    </span><span class="crayon-v">$url</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/api/album/"</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$album_id</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-83"><span class="crayon-h">    </span><span class="crayon-k ">return</span><span class="crayon-h"> </span><span class="crayon-e">curl_get</span><span class="crayon-sy">(</span><span class="crayon-v">$url</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-84"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-85"> </div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-86"><span class="crayon-t">function</span><span class="crayon-h"> </span><span class="crayon-e">get_playlist_info</span><span class="crayon-sy">(</span><span class="crayon-v">$playlist_id</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-87"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-88"><span class="crayon-h">    </span><span class="crayon-v">$url</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/api/playlist/detail?id="</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$playlist_id</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-89"><span class="crayon-h">    </span><span class="crayon-k ">return</span><span class="crayon-h"> </span><span class="crayon-e">curl_get</span><span class="crayon-sy">(</span><span class="crayon-v">$url</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-90"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-91"> </div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-92"><span class="crayon-t">function</span><span class="crayon-h"> </span><span class="crayon-e">get_music_lyric</span><span class="crayon-sy">(</span><span class="crayon-v">$music_id</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-93"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-94"><span class="crayon-h">    </span><span class="crayon-v">$url</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/api/song/lyric?os=pc&id="</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-v">$music_id</span><span class="crayon-h"> </span><span class="crayon-sy">.</span><span class="crayon-h"> </span><span class="crayon-s">"&lv=-1&kv=-1&tv=-1"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-95"><span class="crayon-h">    </span><span class="crayon-k ">return</span><span class="crayon-h"> </span><span class="crayon-e">curl_get</span><span class="crayon-sy">(</span><span class="crayon-v">$url</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-96"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-97"> </div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-98"><span class="crayon-t">function</span><span class="crayon-h"> </span><span class="crayon-e">get_mv_info</span><span class="crayon-sy">(</span><span class="crayon-sy">)</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-99"><span class="crayon-sy">{</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-100"><span class="crayon-h">    </span><span class="crayon-v">$url</span><span class="crayon-h"> </span><span class="crayon-o">=</span><span class="crayon-h"> </span><span class="crayon-s">"http://music.163.com/api/mv/detail?id=319104&type=mp4"</span><span class="crayon-sy">;</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-101"><span class="crayon-h">    </span><span class="crayon-k ">return</span><span class="crayon-h"> </span><span class="crayon-e">curl_get</span><span class="crayon-sy">(</span><span class="crayon-v">$url</span><span class="crayon-sy">)</span><span class="crayon-sy">;</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-102"><span class="crayon-sy">}</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-103"> </div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-104"><span class="crayon-c">#echo music_search("Moon Without The Stars", "1");</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-105"><span class="crayon-c">#get_music_info("28949444");</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-106"><span class="crayon-c">#echo get_artist_album("166009", "5");</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-107"><span class="crayon-c">#echo get_album_info("3021064");</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-108"><span class="crayon-c">#echo get_playlist_info("22320356");</span></div><div class="crayon-line" id="crayon-5aa39c0c2ed42507386183-109"><span class="crayon-c">#echo get_music_lyric("29567020");</span></div><div class="crayon-line crayon-striped-line" id="crayon-5aa39c0c2ed42507386183-110"><span class="crayon-c">#echo get_mv_info();</span></div></div></td> </tr> </tbody></table> </div> </div>

 

PS:搜索的接口我用CURL调用失败,原因未知,于是搜索是用文件操作实现的

转自Moonlib的博客:http://moonlib.com/606.html

转载请注明原文地址: https://www.6miu.com/read-2150031.html

最新回复(0)