基于thinkphp的代碼
1:搜索歌曲
接口:
$url="http://soso.music.qq.com/fcgi-bin/fcg_search_xmldata.fcg?source=10&w=".$name."&type=qry_song&out=json&p=1&perpage=50&ie=utf-8&uin=767943994&inCharset=GB2312&outCharset=GB2312&hostUin=767943994?ice=0&needNewCode=0&format=jsonp&platform=musicbox&g_tk=1427201588";
ext_json_decode方法
public function ext_json_decode($str, $mode=false){
if(strpos($str,'},]}')){
$str = str_replace('},]}','}]}',$str);
}
if(preg_match('/\w:/', $str)){
//? $str = preg_replace('/(\w+):/is', '"$1":', $str);
$str = preg_replace('/([^"\{\[\:\,]+)(:(?:true|false|\d|"|\{|\[))/', '"$1"$2',$str);
? }
return json_decode($str, $mode);
}
2:歌曲播放:首先要獲取vkey
1:獲取vkey
$url = 'https://c.y.qq.com/base/fcgi-bin/fcg_music_express_mobile3.fcg';
2:點(diǎn)擊請(qǐng)求vkey的js
$src = "http://dl.stream.qqmusic.qq.com/"+info['filename']+"vkey="+info['vkey']+"&guid="+guid+"&fromtag=66";