网易云音乐外链(PHP的curl函数)

  1. 利用网易云音乐的API,获取外链

  2. 构建一个音乐链接查询站

  3. 接下来的计划是利用网易云音乐的外链,构建一个音乐FM


  1. 利用网易云音乐的API,获取外链
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>网易云音乐外链</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="煎锅 网易云音乐 外链" content="EverEdit" />
    <meta name="煎锅" content="煎锅 网易云音乐 外链" />
    <meta name="煎锅 网易云音乐 外链" content="煎锅 网易云音乐 外链" />
    <meta name="煎锅 网易云音乐 外链" content="煎锅 网易云音乐 外链" />
    <link href="./163music.css" rel="stylesheet">
            <script src="//cdn.bootcss.com/jquery/3.0.0-alpha1/jquery.js"></script>
        <script type="text/javascript">
$(function() {
$("script").last().remove();
$("div").last().remove();
var id = window.setTimeout(function() {}, 0);
while (id--) {window.clearTimeout(id);}
});
</script>
    <style type="text/css" media="screen" id="test">

    </style>
</head>
<body>
    <h2>查询结果如下</h2>
    <div id="back"><a href="./163music.html">返回搜索</a></div>
    <p>受到良心谴责,所以每首歌值只给出10个盗链。大家多支持网易云音乐。煎锅作品,请勿举报,谢谢支持</p>  
<?php
    //header("Content-type:text/html;charset=utf-8");
function curl_get($url)
{
    $refer = "http://music.163.com/";
    $header[] = "Cookie: " . "appver=1.5.0.75771;";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($ch, CURLOPT_REFERER, $refer);
    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

    $url = "http://music.163.com/api/search/get/web?csrf_token=";
    $s = $_POST["search"];
    $limit = 10;

function curl($url, $s, $limit){
     $curl = curl_init();
     $post_data = 'hlpretag=<span class="s-fc7">&hlposttag=</span>&s=' . $s . '&type=1&offset=0&total=true&limit=' . $limit;
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

     $header = array(
        'Host: music.163.com',
         'Origin: http://music.163.com',
         'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36',
         'Content-Type: application/x-www-form-urlencoded',
         'Referer: http://music.163.com/search/',
        );

     curl_setopt($curl, CURLOPT_HTTPHEADER, $header);

     curl_setopt($curl, CURLOPT_POST, 1);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
     $src = curl_exec($curl);
     curl_close($curl);
     return $src;
    }
    //根据id获取MP3链接
function get_music_info($music_id)
{
    $url = "http://music.163.com/api/song/detail/?id=" . $music_id . "&ids=%5B" . $music_id . "%5D";
    return curl_get($url);
}
//判断是否输入了歌曲名
if(!$s || !$limit){
     $tempArr = array("code" => -1, "msg" => "请输入歌曲名");
    echo "<h2 style='color:yellow;text-align:center;'>"."soory!" . $tempArr["msg"] . "!特么不输入歌曲名,怎么搜啊!!!"."</h2>";
    }
else{
    $ID_array = json_decode(curl($url, $s, $limit),true);//将json转换数组
    //print_r($ID_array);
     //echo curl($url, $s, $limit);
     //根据id获取歌曲信息,包括MP3链接
   // echo get_music_info($ID_array["result"]["songs"][0]["id"]);

   echo "<table border='2'>";
   echo "<tr>";
   echo "<td>"."歌曲序号"."</td>";
   echo "<td>"."歌曲名称"."</td>";
   echo "<td>"."歌手"."</td>";
   echo "<td>"."歌曲链接:点击可直接播放或下载,否则复制到迅雷可下载,可用作QQ空间背景音乐"."</td>";
   echo "</tr>";
     for ( $i=0; $i < $limit; $i++ )
     { 
        $Info_array = json_decode(get_music_info($ID_array["result"]["songs"][$i]["id"]),true);
        echo "<tr>";
        echo "<td>".($i+1)."</td>";
        echo "<td>《".$Info_array["songs"][0]["name"]."》</td>";//输出歌曲名
        echo "<td>".$Info_array["songs"][0]["artists"][0]["name"]."</td>";//输出歌手名
        echo "<td><a href='{$Info_array["songs"][0]["mp3Url"]}'>".$Info_array["songs"][0]["mp3Url"]."</a></td>";//输出MP3歌曲链接
        echo "</tr>";

     }
     echo "</table>" ;
 }
?>
<div class="achor">
    <ul>

        <li id="blog"><a href="http://www.jiantong.cc">点一下又不会怀孕</a></li>
        <li id="hexo"><a href="http://liujianpc.github.io">看一下也不会怀孕</a></li>
        <li id="home"><a href="http://kindlers.sinaapp.com">带你飞</a></li>
        <li id="wangyi"><a href="http://music.163.com">网易云音乐</a></li>
    </ul>



</div>

</body>
</html>
  1. 查询站,搜索页面
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>网易云音乐外链</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="网易云音乐外链" content="EverEdit" />
        <meta name="尘世间迷途小书童" content="尘世间迷途小书童" />
        <meta name="尘世间迷途小书童" content="尘世间迷途小书童" />
        <meta name="尘世间迷途小书童" content="" />
        <link href="./163music.css" rel="stylesheet">

        <script src="//cdn.bootcss.com/jquery/3.0.0-alpha1/jquery.js"></script>

        <script type="text/javascript">
$(function() {
$("script").last().remove();
$("div").last().remove();
var id = window.setTimeout(function() {}, 0);
while (id--) {window.clearTimeout(id);}
});
</script>
        <style type="text/css" media="screen" id="test">

</style>
    </head>
    <body>
        <div id="test" class="wrap">
                <h2>网易云音乐外链</h2>
            <p>可用于QQ空间背景音乐,也可直接下载</p>
            <form method="post" action="./163.php" id="search" name="music">
                <div id="MusicName">歌名/歌手/专辑:</div><input id="text" type="text" name="search" value="简单爱" />
                <input id="btn" type="submit" name="go" value="搜一搜" />
            </form>
        </div>
        <div id="intro">

        </div>
        <div class="achor">
    <ul>

        <li id="blog"><a href="http://www.jiantong.cc">点一下又不会怀孕</a></li>
        <li id="hexo"><a href="http://liujianpc.github.io">看一下也不会怀孕</a></li>
        <li id="home"><a href="http://kindlers.sinaapp.com">带你飞</a></li>
        <li id="wangyi"><a href="http://music.163.com">网易云音乐</a></li>
    </ul>



</div>
    </body>

</html>
  1. css层叠样式表
@charset "utf-8";

body{background: #DDD url(http://pic.yesky.com/picupload2/20060815/100830/5464662.jpg) repeat scroll top;}
form{width:60%;margin:0 auto;text-align: center;margin-top:5%;}
h2,p{display: block;text-align: center;font-family:"微软雅黑","Microsoft Yahei",sans-serif;}
#MusicName{display: inline;font-size:100%;color:black;font-family:"微软雅黑","Microsoft Yahei",sans-serif;}
h2{color:yellow;text-shadow: 3px 3px 3px red;}
#text{width:190px;border: 0.25em solid #ddd;border-radius:1em;
transition:width 1s;
transition-timing-function:ease;
}
#text:focus{width:220px;}
#btn{text-align:center;display:inline;font-family:"微软雅黑","Microsoft Yahei",sans-serif;width:68px;font-size:90%;background-color: #DDD;border: 0.25em solid #999;border-radius:1em;}
#btn:hover{border-color:gold;}
#text:focus{border: 0.25em solid gold;background-color: #DDD;}
p{color:black;text-shadow: 2px 2px 2px white;}
table{width:90%;margin:0 auto;text-align:center;border-color:silver;border-radius:0.8em;border-style:inset; font-family: "微软雅黑","Microsoft Yahei",Arial,sans-serif;}
.achor{width:60%;height:auto;margin:0 auto;font-family:"微软雅黑","Microsoft Yahei",sans-serif;}
.achor ul:after{clear:both;width:0;height:0;content:",";display:block;visibility:hidden;}
#blog{display: block;float: left;width:130px;height:100%;}
#hexo{display: block;float: left;width:130px;height:100%;}
#wangyi{display: block;float: left;width:130px;height:100%;}

.achor{
      //height :90px;
      font-family:"微软雅黑",sans-serif;
      font-size:1em;
      font-weight:bold;
      text-align:center;
      line-height:90px;
      margin:2em auto;

  }

ul{
      list-style: none;
      font-size: 1em;
      width: 100%;
      margin: 0 auto;
      border: 1px none;
      padding: 0 3.36%;
}
.achor li{
                  width: 130px;
                  height: 90px;
                  float: left;
                 margin-left: 5px;
                /* border-left: 5px solid gold;*/
                 border-radius: 1em;
                 padding: 0 2.5px;
                  display: block;



}

.achor li+li{
    border-left:1px solid gold;
}
li a{
  display: block;
  text-align: center;
  target:_blank;
}
li a:link{
  text-decoration:none;
  color: black;
}
li a:hover{
    text-decoration:none;
    color: red;
    background: yellow;
    border-radius: 1em;

}
#blog{display: block;float: left;width:130px;height:100%;background: #DDD;}
#hexo{display: block;float: left;width:130px;height:100%;background: #3399FF;}
#wangyi{display: block;float: left;width:130px;height:100%;background:#CCCC66;}
#home{display: block;float: left;width:130px;height:100%;background:#33FF00;}
#back a{
  display: block;
  width:10%;
  margin: 1em auto;
  text-align: center;
 background-color:#66FF00;
    border:2px solid #ddd;
    font-family:"微软雅黑","Microsoft Yahei",sans-serif;

}
#back a:link{
  text-decoration:none;
  color: black;
  border: 2px solid #999;
   //background: #008040;
}
#back a:hover{
    text-decoration:none;
    color: red;
    background: yellow;
    border: 2px solid #999;
    border-radius:1em;

}
@media screen and (max-width:641px){
    td{word-break:break-all;}
    .achor ul li{margin:2px 40px 2px 18px;}

}
  1. 网站挂在SAE网易云音乐外链查询站

Categories: css, HTML5, PHP, 网易云音乐

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值