源码介绍:
网易云音乐热门评论随机API接口纯源码,随机热评。
PHP网易云音乐热评API接口
输出数据格式:josn
直接采集网易音乐调用,非第三方接口!
刷新php文件即可展示随机不同的网易最新热门音乐播放连接、热评、名称标题、简介、封面图等等!
代码如下:
<?php
header('Content-type: text/json;charset=utf-8');
$format =$_GET['format'];;
$post = 'params=RWWaVrwvMRFMFc6r%2BrKTq66XIh8o1s%2BP%2BebgYma%2FWimi6K5F3KtWHtpXfC%2Fgh77TtCtc3rmpHuknSe%2BDi%2FNBycqi9m7nISKeQx9Z46RmucLioCQeGmOKJ%2FJJ2FFquMvqj0U2NAoD%2BmN1zc7l39CKLQm4A%2Bz4yt2r9n2EJPc4XZpGorDx7fvTY4ulvRg93keo5r4cpfihdIAara8uU1k3IW6ohE%2BLuguCMstPnzQJgDU%3D&encSecKey=0be524c8f3210f9fe781abc2682012b97d13f843e74b92b42955ab0ddb0964ffdf7c8a01138342307bfc0d2544f8a1131c9dc72c95b8fae31dc603bf5c00d090f730428b9d73eb151d563bf7b816518d1a1c5ad4a37f4fffa1700469151025f2fc282edbb70d6217d3054c2cb90649aa2b645ad38baaccbfb90eb28e720ef56a';
$music = get_music_list($post);
if($format == 'text') {
$result = $music['content'].PHP_EOL;
$result .= '来自@'. $music['nickname'];
$result .= '在「'.$music['name'].'」'.PHP_EOL;
$result .= '歌曲下方的评论'.PHP_EOL;
$result .= $music['copyright'];
print_r($result);
}else{
$result = json_encode(array(
'code' => 1,
'data' => $music
),320);
print_r($result);
}
function get_music_list($post){
$rel = G163_curl('https://music.163.com/weapi/playlist/detail', $post);
$arr = json_decode($rel,true)['result']['tracks'];
$music = $arr[array_rand($arr,1)];
$rel = G163_curl('https://music.163.com/weapi/v1/resource/comments/R_SO_4_'.$music['id'], $post);
$arr = json_decode($rel,true)['hotComments'];
$hotComments = $arr[array_rand($arr,1)];
$data = array(
'name' => $music['name']
,'url' => 'http://music.163.com/song/media/outer/url?id='.$music['id'].'.mp3'
,'picurl' => $music['album']['picUrl']
,'artistsname' => $music['artists'][0]['name']
,'avatarurl' => $hotComments['user']['avatarUrl']
,'nickname' => $hotComments['user']['nickname']
,'content' => $hotComments['content']
,'copyright' => '更多源码请访问www.lmeim.cn'
);
return $data;
}
function G163_curl($url, $post=0, $referer=0, $cookie=0, $header=0, $ua=0, $nobaody=0){
$ch = curl_init();
$ip = rand(0,255).'.'.rand(0,255).'.'.rand(0,255).'.'.rand(0,255) ;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:application/json";
$httpheader[] = "Accept-Encoding:gzip, deflate, br";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Accept-Type:application/x-www-form-urlencoded";
$httpheader[] = "Origin:https://music.163.com";
$httpheader[] = "Origin:https://music.163.com";
$httpheader[] = 'X-FORWARDED-FOR:'.$ip;
$httpheader[] = 'CLIENT-IP:'.$ip;
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($post) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if ($header) {
curl_setopt($ch, CURLOPT_HEADER, true);
}
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if($referer){
if($referer==1){
curl_setopt($ch, CURLOPT_REFERER, 'https://music.163.com/outchain/player?type=0&id=2250011882&auto=1');
}else{
curl_setopt($ch, CURLOPT_REFERER, $referer);
}
}
if ($ua) {
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
}
else {
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1");
}
if ($nobaody) {
curl_setopt($ch, CURLOPT_NOBODY, 1);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_INTERFACE, '172.21.0.'.rand(10,27));
$ret = curl_exec($ch);
//$Headers = curl_getinfo($ch);
curl_close($ch);
return $ret;
}
版权声明:本文内容来源于互联网资源,由 蓝魅网络 整理汇总,如有侵权请您与我们联系删除!
其他声明:如未标明出处,所有文章均为蓝魅网络原创,转载请务必保留本文链接,感谢您支持。
蓝魅网络 » PHP网易云音乐热评API接口代码,直接采集网易音乐调用
其他声明:如未标明出处,所有文章均为蓝魅网络原创,转载请务必保留本文链接,感谢您支持。
蓝魅网络 » PHP网易云音乐热评API接口代码,直接采集网易音乐调用
-
售后服务范围 1、商业模板使用范围内问题免费咨询 2、源码安装、模板安装(一般 ¥50-300)服务答疑仅限会员用户 3、单价超过200元的模板即可以免费一次安装,需提供服务器信息 付费增值服务 1、提供dedecms模板、WordPress主题、discuz模板优化等服务请详询在线客服 2、承接 WordPress、DedeCMS、Discuz 等系统建站、仿站、开发、定制等服务 3、服务器环境配置安装(一般 ¥50-300) 4、网站中毒处理(需额外付费,500元/次/质保三个月) 售后服务时间 周一至周日(法定节假日除外) 9:00-23:00 免责声明提示 本站所提供的资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: 495553705@qq.com),我们会及时删除,给您带来的不便,我们深表歉意!