admin 管理员组

文章数量: 887021

php文件直链源码,PHP

没什么技术含量的东西..

找源

找到需要下载的歌曲,然后分享,复制一下链接.

这个随便找一个:

//分享链接会泄露个人信息,我就*代替了

=**********&shareuid=********&topsource=a0_pn201001006_z11_u10923685_l0_t1577770997__

右键查看源码:

你会发现这其实一个 JSON 数据...那么就不用说了..

源码

header('content-type:application/json');

$url = @$_GET['url'];

if (empty($url)) {

echo json_encode(['code' => 1, 'msg' => '没有播放链接'], 320);

exit;

}

$data = curlGet($url);

$jsonData = getsubstr($data, 'window.__DATA__ = ', ';');

$jsonArr = json_decode($jsonData, true);

$play = [

'avatar' => $jsonArr['detail']['avatar'], //歌手头像

'content' => $jsonArr['detail']['content'], //分享内容

'cover' => $jsonArr['detail']['cover'], //歌曲封面

'nick' => $jsonArr['detail']['kg_nick'], //歌手昵称

'playurl' => $jsonArr['detail']['playurl'], //mp3 下载地址

];

echo json_encode($play, 320);

// 取中间文本函数

function getsubstr($str, $leftStr, $rightStr) {

$left = strpos($str, $leftStr);

$right = strpos($str, $rightStr, $left);

if ($left < 0 or $right < $left) {

return '';

}

return substr($str, $left + strlen($leftStr), $right - $left - strlen($leftStr));

}

function curlGet($url) {

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0');

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

$output = curl_exec($ch);

curl_close($ch);

return $output;

}

TEST 一下

OJ8K!

~谢谢打赏~

本文标签: php文件直链源码 php