网站LOGO
友幻猫
页面加载中
2月24日
网站LOGO 友幻猫
夜雨闻卿至🎞️清酒待君归
菜单
  • 友幻猫
    夜雨闻卿至🎞️清酒待君归
    用户的头像
    首次访问
    上次留言
    累计留言
    我的等级
    我的角色
    打赏二维码
    打赏博主
    音乐解析接口
    点击复制本页信息
    微信扫一扫
    文章二维码
    文章图片 文章标题
    创建时间
  • 一 言
    确认删除此评论么? 确认
  • 本弹窗介绍内容来自,本网站不对其中内容负责。

    音乐解析接口

    猫语 · 原创 ·
    知识星球综合教程 · API音乐解析
    共 4763 字 · 约 1 分钟 · 22
    QQ音乐解析
    php 代码:
    function QqMusic($song)
    {
        $url = 'https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg?_=1700916409115&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8&notice=0&platform=yqq.json&needNewCode=1&uin=542020206&g_tk_new_20200303=151942930&g_tk=151942930&hostUin=0&is_xml=0&key=' .$song;
        $Response = json_decode(MyRequest($url ,""),true);
        $song_id = $Response['data']['song']['itemlist'][0]['mid'];
        $url = 'https://u.y.qq.com/cgi-bin/musicu.fcg?g_tk=5381&uin=542020206&format=json&data=%7B%22comm%22%3A%7B%22ct%22%3A23%2C%22cv%22%3A0%7D%2C%22data_mid%22%3A%7B%22module%22%3A%22track_info.UniformRuleCtrlServer%22%2C%22method%22%3A%22GetTrackInfo%22%2C%22param%22%3A%7B%22mids%22%3A%5B%22' .$song_id .'%22%5D%2C%22types%22%3A%5B0%5D%7D%7D%2C%22url_mid%22%3A%7B%22module%22%3A%22vkey.GetVkeyServer%22%2C%22method%22%3A%22CgiGetVkey%22%2C%22param%22%3A%7B%22guid%22%3A%22909207337%22%2C%22songmid%22%3A%5B%22' .$song_id .'%22%5D%2C%22songtype%22%3A%5B0%5D%2C%22uin%22%3A%22542020206%22%2C%22loginflag%22%3A0%2C%22platform%22%3A%2223%22%7D%7D%7D&_=1700929770192';
        $Response = json_decode(MyRequest($url , QqCookies()),true);
        $song_title = $Response['data_mid']['data']['tracks'][0]['name'];
        $song_artist = $Response['data_mid']['data']['tracks'][0]['singer'][0]['name'];
        $song_album = $Response['data_mid']['data']['tracks'][0]['album']['name'];
        $song_pmid  = $Response['data_mid']['data']['tracks'][0]['album']['pmid'];
        $song_cover =  'https://y.qq.com/music/photo_new/T002R300x300M000'.$song_pmid.'.jpg?max_age=2592000';
        $song_link =   $Response['url_mid']['data']['midurlinfo'][0]['purl'];
        $song_lyrics = "";
    
        $song = [
        "id" => $song_id,
        "song" => $song_title,
        "singer" => $song_artist,
        "album" => $song_album,
        "cover" => $song_cover,
        "play" => $song_link,
        "lyrics" => $song_lyrics
        ];
        if($song_link === ""){
            return "歌曲解析失败,可能为平台限制类型歌曲";
        }
        return json_encode($song,JSON_UNESCAPED_UNICODE);
    }
    网易云音乐解析
    php 代码:
    function WyMusic($song)
    {
        $url = "https://music.163.com/api/search/get/web?limit=1&type=1&s=" .rawurlencode($song);
        $Response = json_decode(MyRequest($url , WyCookies()),true);
        $song_id = $Response['result']['songs'][0]['id'];
        $song_title = $Response['result']['songs'][0]['name'];
        $song_artist = $Response['result']['songs'][0]['artists'][0]['name'];
        $song_album = $Response['result']['songs'][0]['album']['name'];
        $song_cover =  $Response['result']['songs'][0]['artists'][0]['img1v1Url'];
        $song_link =   'http://music.163.com/song/media/outer/url?id='.$song_id. '.mp3';
        $song_lyrics = "";
    
        $song = [
        "id" => $song_id,
        "title" => $song_title,
        "artist" => $song_artist,
        "album" => $song_album,
        "cover" => $song_cover,
        "play" => $song_link,
        "lyrics" => $song_lyrics
        ];
        if($song_link === ""){
            return "歌曲解析失败,可能为平台限制类型歌曲";
        }
        return json_encode($song,JSON_UNESCAPED_UNICODE);
    }
    
    酷狗音乐解析
    php 代码:
    function KgMusic($song)
    {
        $url = "http://mobilecdn.kugou.com/api/v3/search/song?format=json&page=1&pagesize=1&showtype=1&keyword=" .$song;
        $Response = json_decode(MyRequest($url , KgCookies()),true);
        $song_id = $Response['data']['info'][0]['hash'];
        $song_title = $Response['data']['info'][0]['songname'];
        $song_artist = $Response['data']['info'][0]['group'][0]['singername'];
        $song_album = $Response['data']['info'][0]['album_name'];
        $Response = json_decode(MyRequest("https://m.kugou.com/app/i/getSongInfo.php?cmd=playInfo&hash=" .$song_id , "PE", ""),true);
        $song_cover = $Response['imgUrl'];
        $song_link = $Response['url'];
        $song_lyrics = "";
        $song = [
        "id" => $song_id,
        "title" => $song_title,
        "artist" => $song_artist,
        "album" => $song_album,
        "cover" => $song_cover,
        "play" => $song_link,
        "lyrics" => $song_lyrics
        ];
        if($song_link === ""){
            return "歌曲解析失败,可能为平台限制类型歌曲";
        }
        return json_encode($song,JSON_UNESCAPED_UNICODE);
    }
    web请求函数
    php 代码:
    function MyRequest($API_URL,$cookies)
        {
            $ch = curl_init();  
            curl_setopt($ch, CURLOPT_URL, $API_URL);
            curl_setopt($ch, CURLOPT_REFERER, $API_URL);
            curl_setopt($ch, CURLOPT_COOKIE, $cookies);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            $resdata = curl_exec($ch);
            curl_close($ch);
            return $resdata;
        }
    声明:本文由 猫语(博主)原创,依据 CC-BY-NC-SA 4.0 许可协议 授权,转载请注明出处。

    还没有人喜爱这篇文章呢

    发一条! 发一条!
    博客logo 友幻猫 夜雨闻卿至🎞️清酒待君归
    ICP 豫ICP备2022018876号-1 ICP 豫公网安备41142502000136号 又拍云 本站由又拍云提供CDN加速/云存储服务

    🕛

    本站已运行 54 天 18 小时 10 分
    友幻猫. © 2024 ~ 2024.
    网站logo

    友幻猫 夜雨闻卿至🎞️清酒待君归
     
     
     
     
    壁纸