QQ音乐【多选】

对接QQ音乐,超多正版音乐免费在线免费听,返回为json,需返回其他格式请自行修改输出格式。

注:部分用户反馈国外服务器获取的播放链接无效,能否使用请自测。

<?php
$msg = $_GET['msg'];
$b = $_GET['n'];
$data=curl('http://c.y.qq.com/soso/fcgi-bin/client_search_cp?ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.center&searchid=43077615819536990&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=1&n=15&g_tk=727196045&jsonpCallback=&loginUin=1828222534&hostUin=0&format=jsonp&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq&needNewCode=0&w='.$msg);
$data=str_replace(')','',$data);
$data=str_replace('callback(','',$data);
$json = json_decode($data, true);
//print_r($json);exit;
$s=count($json["data"]["song"]["list"]);
if($s==0){exit("抱歉,返回数据为空。");}
if($b==""){
for( $i = 0 ; $i < $s ; $i ++ ){
$ga=$json["data"]["song"]["list"][$i]["name"];
$gb=$json["data"]["song"]["list"][$i]["singer"][0]["name"];
$pay = $json["data"]["song"]["list"][$i]["pay"]["pay_play"];
if($pay=="0"){
$pay="[免费]";}else{
$pay="[收费]";
}
echo ($i+1).":".$ga."--".$gb."".$pay."\n";}}else{
$i=($b-1);
$mid=$json["data"]["song"]["list"][$i]["mid"];
$j=curl_id($mid);
$tu="http://y.gtimg.cn/music/photo_new/T002R500x500M000".$json["data"]["song"]["list"][$i]["album"]["pmid"].".jpg";
$ga=$json["data"]["song"]["list"][$i]["name"];//获取歌名
$gb=$json["data"]["song"]["list"][$i]["singer"][0]["name"];//获取歌手
echo 'json:{"app":"com.tencent.structmsg","desc":"音乐","view":"music","ver":"0.0.0.1","prompt":"[分享]'.$ga.'","appID":"","sourceName":"","actionData":"","actionData_A":"","sourceUrl":"","meta":{"music":{"action":"","android_pkg_name":"","app_type":1,"appid":100497308,"desc":"'.$gb.'","jumpUrl":"https://i.y.qq.com/v8/playsong.html?platform=11&appshare=android_qq&appversion=9060506&hosteuin=oio5oKEsoenzNv**&songmid='.$mid.'&type=0&appsongtype=1&_wv=1&source=qq&sharefrom=gedan","musicUrl":"'.$j.'","preview":"'.$tu.'","sourceMsgId":"0","source_icon":"","source_url":"","tag":"QQ音乐","title":"'.$ga.'"}},"config":{"autosize":true,"ctime":1575625127,"forward":true,"token":"7fef9b7d1e63b3500a42462126e9bc3d","type":"normal"},"text":"","sourceAd":""}';//,"config":{"forward":0,"showSender":0}
}

function get_millisecond(){
list($usec, $sec) = explode(" ", microtime());
$msec=round($usec*1000);
return $msec;
}

function curl_id($songmid) {
list($usec, $sec) = explode(" ", microtime());
$msec=round($usec*1000);
$post='{"comm":{"uin":"12345678","authst":"Q_H_L_2GkSAt50ee8gzIxBfwVxm4zic4SoFWtBe7jn4KeVgsdv-i16zip19RIMmP_JJ59","mina":1,"appid":1109523715,"ct":29},"urlReq":{"module":"vkey.GetVkeyServer","method":"CgiGetVkey","param":{"guid":"'.$msec.'","songmid":["'.$songmid.'"],"songtype":[0],"uin":"12345678","loginflag":1,"platform":"23","h5to":"speed"}}}';
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,"https://u.y.qq.com/cgi-bin/musicu.fcg");
curl_setopt($curl,CURLOPT_POST,1);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl,CURLOPT_REFERER,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.30 Safari/537.36');
curl_setopt($curl,CURLOPT_COOKIE,'qqmusic_uin=12345678; qqmusic_key=12345678; qqmusic_fromtag=30; ts_last=y.qq.com/portal/player.html;');
curl_setopt($curl,CURLOPT_USERAGENT,"http://y.qq.com/portal/player.html");
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$result=curl_exec($curl);
curl_close($curl);
preg_match_all('/"purl": "(.*?)"/',$result,$c);
$j=$c[1][0];
preg_match_all('/"testfilewifi": "(.*?)"/',$result,$c);
$j1=$c[1][0];
if($j==""){
$j=$j1;}
return "http://dl.stream.qqmusic.qq.com/".$j;
}

function curl($url,$data=0,$header_array=0,$referer=0,$time=30,$code=0) {
if($header_array==0) {
$header=array("CLIENT-IP: ".ip(),"X-FORWARDED-FOR: ".ip(),'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36');
} else {
$header=array("CLIENT-IP: ".ip(),"X-FORWARDED-FOR: ".ip(),'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36');
$header=array_merge($header_array,$header);
}
$curl=curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
if($data) {
curl_setopt($curl,CURLOPT_POST,1);
curl_setopt($curl,CURLOPT_POSTFIELDS,$data);}
if($referer){
curl_setopt($curl,CURLOPT_REFERER,$referer);}
curl_setopt($curl,CURLOPT_TIMEOUT,$time);
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl,CURLOPT_ENCODING,'gzip,deflate');
if($code){
curl_setopt($curl, CURLOPT_HEADER, 1);
$return=curl_exec($curl);
$code_code=curl_getinfo($curl);
curl_close($curl);
$code_int['exec']=substr($return,$code_code["header_size"]);
$code_int['code']=$code_code["http_code"];
$code_int['content_type']=$code_code["content_type"];
$code_int['header']=substr($return,0,$code_code["header_size"]);
return $code_int;
}else{
$return=curl_exec($curl);
curl_close($curl);
return $return;}}
function ip(){
$ip_long = array(
array('607649792','608174079'),
array('1038614528','1039007743'),
array('1783627776','1784676351'),
array('2035023872','2035154943'),
array('2078801920','2079064063'),
array('-1950089216','-1948778497'),
array('-1425539072','-1425014785'),
array('-1236271104', '-1235419137'),
array('-770113536','-768606209'),
array('-569376768','-564133889'),);
$rand_key=mt_rand(0,9);
return $ip=long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
}
?>

使用方法请参照:慕名API

分类:接口源码        发布时间:2020-09-20 17:10:52
来源:网页端         浏览量:1613

共有0条评论!

发表评论

更换一道题!