PHP-全民K歌直链信息解析源码
找到需要下载的歌曲,然后分享,复制一下链接.
这个随便找一个:
- //分享链接会泄露个人信息,我就*代替了
- https://node.kg.qq.com/play?s=**********&shareuid=********&topsource=a0_pn201001006_z11_u10923685_l0_t1577770997__
右键查看源码:
你会发现这其实一个 JSON 数据…那么就不用说了..
源码
- php
-
- 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,
版权声明:
作者:超级管理员
链接:
https://apecloud.ltd/article/detail.html?id=66
来源:猿码云个人技术站
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
打赏
共有0条评论