在线获取外链的php源码,y.qq.com-php获取QQ音乐外链源码

作者:matrix

被围观: 8,000 次

发布时间:2015-05-18

分类:零零星星 |

22 条评论 »

💡NOTICE:这是一个创建于 2123 天前的主题,其中的信息可能已经有所发展或是发生改变。

79a9b93ac251e61e6668964a920f9ef1.png

MP3接口

http://tsmusic24.tc.qq.com/{音乐ID}.mp3

http:/ /stream.qqmusic.tc.qq.com/{音乐ID}.mp3

http:/ /stream{1-30都可以}.qqmusic.qq.com/{音乐ID}.mp3

http://tsmusic128.tc.qq.com/{音乐ID+30000000}.mp3 (请计算出结果)

QQ音乐高品质ogg

http://tsmusic128.tc.qq.com/{音乐ID+40000000}.ogg (请计算出结果)

M4A接口

http://tsmusic24.tc.qq.com/{音乐ID}.m4a

http://thirdparty.gtimg.com/{音乐ID}.m4a?fromtag=38

http://thirdparty.gtimg.com/C100{音乐MID}.m4a?fromtag=38

http://cc.stream.qqmusic.qq.com/C200{音乐MID}.m4a?vkey={VKEY的值}&guid=1830679348

过程

示例获取单曲页面的MP3或M4A文件链接

http://y.QQ.com/#type=song&mid=002G0sJY2wThyx

其中的002G0sJY2wThyx就是歌曲的mid

打开上面的URl浏览器会加载iframe框架http://s.plcloud.music.QQ.com/fcgi-bin/fcg_yqq_song_detail_info.fcg?songmid=002G0sJY2wThyx

Ctrl +U查看源码

var g_SongData = { id: 7168586, songmid: '002G0sJY2wThyx', songname: '喜欢你', singer:'G.E.M. 邓紫棋', singerid:13948,singermid:'001fNHEf1SFEFN',albumname:'喜欢你', albumid:654246,albummid:'000cFPKx3ZGzks', status:31, fnote:0};/*status:非0(true)表示正常歌曲,0(false)表示下架歌曲或者歌曲不存在*/

说明:其中的7168586就是对应歌曲的id,而002G0sJY2wThyx是歌曲的mid,每首歌曲的信息都不同,这需要使用正则匹配数据

php代码:

$u = $_GET['u'];

$type = $_GET['t']?$_GET['t']:'mp3';

$con = 'http://s.plcloud.music.qq.com/fcgi-bin/fcg_yqq_song_detail_info.fcg?songmid='.$u;

preg_match('|var g_SongData = ({.*});|',file_get_contents($con),$data);

$obj = json_decode(format_ErrorJson(iconv('GBK', 'UTF-8', $data[1])));

$id = $obj->id;

//$mid = $obj->songmid;

$url = 'http://tsmusic24.tc.qq.com/'.$id.'.'.$type;

header('Location: '.$url);

function format_ErrorJson($data)

{

$con = str_replace('\'','"',$data);//替换单引号为双引号

$con = preg_replace('/(\w+):[ {]?((?"?).*?\k[,}]?)/is', '"$1": $2',$con );//若键名没有双引号则添加

return $con;

}

说明:

上面代码只是用了MP3和M4A的第一种接口

代码保存为php文件,调用/xxx.php?u=音乐ID&t=格式

例如001yJypt4E8GW0歌曲的m4a地址

/xxx.php?u=001yJypt4E8GW0&t=m4a

MP3和M4A的前三种接口只需要知道歌曲MID即可,但是M4A接口的第4种还需要vkey

vkey的获取只是多个步骤:

打开http://base.music.qq.com/fcgi-bin/fcg_musicexpress.fcg?json=3&guid=1830679348&g_tk=938407465&loginUin=0&hostUin=0&format=jsonp&inCharset=GB2312&outCharset=GB2312&notice=0&platform=yqq&jsonpCallback=&needNewCode=0

可以看到

jsonCallback({"code":0,"sip":["http://cc.stream.qqmusic.qq.com/","http://ws.stream.qqmusic.qq.com/","http://110.188.3.18/streamoc.music.tc.qq.com/"] ,"thirdip":["http://110.188.2.204/abcd1234/", "http://110.188.2.204/abcd1234/"],"key": "AC783A806083897C7C94F8376DD7BA17A37DB5BC3E28CEC35E065092C0E5F46AE0C1F2548CD6CD3048963926B361AC4F7EA62F51A98854F3"});

里面的key对应的值就是vkey

MP3 试听:

/**

* author: pang

* 举例:/?qq=107763168&format=mp3

* 举例:/?qq=107763168&format=m4a

* BUT:有些MP3地址是无法获取的

*

*/

error_reporting(0);

function curl_get($url )

{

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7D11 Safari/528.16'));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$get_url = curl_exec($ch);

curl_close($ch);

return $get_url;

}

if($qqMusic = $_GET['qq']){//qq音乐

function mid2idObj($mid)

{

//20160806 修改

/*$array = array();

$url = 'http://i.y.qq.com/s.plcloud/fcgi-bin/fcg_list_songinfo_cp.fcg?url=2&callback=&midlist='.$mid;

$con = curl_get($url);

$o = json_decode($con);

$array['id'] = $o->data[0]->songid?$o->data[0]->songid:tui('NOT FOUND ->data[0]->songid');

$array['320kbps'] = $o->data[0]->size320?true:false;//检测320kbos资源是否存在

$array['mp3'] = $o->url1->$array['id'];

$array['m4a'] = $o->url->$array['id'];

return $array;*/

if(is_numeric($mid)){

return $mid;

}

$url = 'http://i.y.qq.com/v8/playsong.html?songmid='.$mid;

$con = curl_get($url );

preg_match('~songlist=(.*?)}catch~',$con,$json_);

$o = json_decode($json_[1]);

//$o[0]->songid;

return $o[0];

}

$id_ARR = mid2idObj($qqMusic);

$id = is_numeric($qqMusic)?$qqMusic:$id_ARR->songid;

$url_mp31 = "http://tsmusic24.tc.qq.com/{$id}.mp3";//为320kbps

$url_mp32 = "http://stream.qqmusic.tc.qq.com/{$id}.mp3";//为320kbps

//http://stream.qqmusic.tc.qq.com/C200002HPwXB1sTJG8.mp3 //320kbps 002HPwXB1sTJG8为mid

// $url_mp33 = $id_ARR['mp3'];//为128kbps

$url_m4a1 = "http://thirdparty.gtimg.com/C100{$qqMusic}.m4a?fromtag=38";

$url_m4a2 = "http://thirdparty.gtimg.com/{$id}.m4a?fromtag=38";

$url_m4a3 = "http://tsmusic24.tc.qq.com/{$id}.m4a";

$url_m4a4 = $id_ARR->m4aUrl;

if('mp3' == $_GET['format'])

{

//if('320' == $_GET['kbps'] )

//{

$dl = ${'url_mp3'.mt_rand(1,2)};

$dl .= '?&return=320kbps';

//}

/*else

{

$dl = $url_mp33.'&return=128kbps';

}*/

}

else

{

$dl = ${'url_m4a'.mt_rand(1,4)};

}

header('location: '.$dl);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值