admin管理员组文章数量:1656248
首先需要在阿里云API产品中进行购买QQ音乐接口,然后进行配置,因为调用接口次数有限,所以我们需把获取的内容放到文件中,让接口一天重新进行获取一次数据,这样可以节省次数还不耽误接口音乐的更新。下面是代码的演示,可直接使用,只需填写自己的appcode即可
time())
{
$data=json_decode(file_get_contents("music.log"),true);
}else
{
unlink("music.log");
$data=getData();
}
}else{
$data=getData();
}
function getData(){
$host = "https://ali-qqmusic.showapi";
$path = "/top";
$method = "GET";
$appcode = "***********";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "topid=5";
$bodys = "";
$url = $host . $path . "?" . $querys;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
if (1 == strpos("$".$host, "https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$music=curl_exec($curl);
$msc=json_decode($music,true);
$data=$msc['showapi_res_body']['pagebean']['songlist'];
file_put_contents("music.log",json_encode($data));
return $data;
}
?>
QQmusic
$v){ ?>
版权声明:本文标题:QQ音乐首页接口 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1729732980a1211552.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论