admin管理员组

文章数量:1656247

              首先需要在阿里云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