天天动听外链php源码

作者:matrix 被围观: 7,196 次 发布时间:2014-03-30 分类:兼容并蓄 零零星星 | 32 条评论 »

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

天天动

接口一:http://ting.hotchanson.com/detail.do?neid=音乐ID&size=0

接口二:http://ting.hotchanson.com/website/ting?song_id=音乐ID&code=音乐ID的KEY&from=search

使用接口二较为费劲,需要得到key。

以接口一示例:

打开http://ting.hotchanson.com/detail.do?neid=574285&size=0可以看到

{"code":1,"msg":"OK","data":{"hotList":[],"num":79230,"singerId":4140,"albumName":"Versus","source":"http://lty.bla.enligner.com","count":79095,"singerName":"Usher","itemList":[{"fileType":"压缩品质","dType":1,"downUrl":"http://ws.cs.hotchanson.com/mp3_64_5/52/d4/52ca1c3dcb8e4895de7024b115e45ed4.mp3?k=347f92be0b97ffb3&t=1396579062","size":"1.70M","duration":"03:42"},{"fileType":"标准品质","dType":2,"downUrl":"http://jdlbqc.tgg.yymommy.com/m4a_96_5/52/d4/52ca1c3dcb8e4895de7024b115e45ed4.m4a?k=347f92be0b97ffb3&t=1396579062","size":"2.55M","duration":"03:42"},{"fileType":"标准品质","dType":3,"downUrl":"http://nie.dfe.yymommy.com/mp3_128_5/52/d4/52ca1c3dcb8e4895de7024b115e45ed4.mp3?k=347f92be0b97ffb3&t=1396579062","size":"3.39M","duration":"03:42"}],"publish":"","songName":"DJ Got Us Fallin' In Love","neid":574285}}

之后再从中匹配到需要的mp3链接跳转下载,这就做到外链了。

php代码: 150323修改


<?php if ($_GET['u']) { $id = (is_numeric($_GET['u'])) ? $_GET['u'] : die('Do not see the expected value');//如果没有数字型的GET参数则退出 $url = "http://ting.hotchanson.com/detail.do?neid=$id&size=0";//拼接数据地址 $con = file_get_contents($url);//获取音乐ID的数据 $obj = json_decode($con);//准备提取json数据 $d = ($obj->data->itemList) ? $obj->data->itemList : die('Not Found "itemList"');//如果没有mp3的数据则退出 foreach ($d as $a) {//开始foreach循环遍历每个MP3链接 if (strpos($a->downUrl, ".mp3") && ($a->fileType == '压缩品质' || '标准品质'))//如果有.mp3且为'压缩品质' || '标准品质'则302跳转,否则继续找 { header('Location: ' . $a->downUrl); break; } else { continue; } } }

说明:

上面代码保存为.php文件。

调用格式:http://XXXX/*.php?u=音乐ID

各行都有注释,不再细说。

再说接口二:

这接口二的玩意有些麻烦,不建议使用。

需要的话只是多一个步骤,得到key。

之前我也没注意这key是哪里来的,后来才晓得是js函数算出来的。

var u = {
song_id: t.song_id,
code: $.CRC32(t.song_id),
from: "search"
};

上面的第三行的CRC32()就是获取key的相关函数,里面的t.song_id是音乐ID
又从他页面上的其他js里找到这个代码,看来没错:

CRC32: function(f) {
    var d = new Array(256);
    var e, c;
    var b;
    for (e = 0; e < 256; e++) {
        b = e;
        for (c = 0; c < 8; c++) { if (b & 1) { b = ((b >> 1) & 2147483647) ^ 3988292384
        } else {
            b = ((b >> 1) & 2147483647)
        }
        }
        d[e] = b
    }
    if (typeof f != "string") {
        f = "" + f
    }
    b = 4294967295;
    for (e = 0; e < f.length; e++) { b = ((b >> 8) & 16777215) ^ d[(b & 255) ^ f.charCodeAt(e)]
    }
    b ^= 4294967295;
    return (b >> 3).toString(16)
},

这就是获取key的 CRC32函数。
然后再依葫芦画瓢翻译成php代码,Bingo!

function co($f) {
    $d = Array();
    $e = '';
    $c = '';
    $b = '';
    for ($e = 0; $e < 256; $e++) {
        $b = $e;
        for ($c = 0; $c < 8; $c++) {
            if ($b & 1) {
                $b = (($b >> 1) & 2147483647) ^ 3988292384;
            } else {
                $b = (($b >> 1) & 2147483647);
            }
        }
        $d[$e] = $b;
    }
    if (!is_string($f)) {
        $f = "" + $f;
    }
    $b = 4294967295;
    for ($e = 0; $e < strlen($f); $e++) {
        $b = (($b >> 8) & 16777215) ^ $d[($b & 255) ^ get_bianma(substr($f, $e, 1))];
    }
    $b ^= 4294967295;// $b = $b ^ 4294967295;
    $fuhao = (!is_numeric(substr($b >> 3, 0, 1))) ? substr($b >> 3, 0, 1) : '';
    return $fuhao.base_convert($b >> 3, 10, 16);//base_convert会去掉($b >> 3)的负号,这里不要用dechex()转换为16进制
}

function get_bianma($str)//等同于js的charCodeAt()
{
    $result = array();
    for ($i = 0, $l = mb_strlen($str, 'utf-8'); $i < $l; ++$i) {
        $result[] = uniord(mb_substr($str, $i, 1, 'utf-8'));
    }
    return join(",", $result);
}

function uniord($str, $from_encoding = false) {
    $from_encoding = $from_encoding ? $from_encoding : 'UTF-8';
    if (strlen($str) == 1)
        return ord($str);
    $str = mb_convert_encoding($str, 'UCS-4BE', $from_encoding);
    $tmp = unpack('N', $str);
    return $tmp[1];
}

说明:代码放到php文件的<?php 和?>之间
echo co('1757517');//显示出音乐id为1757517的KEY
之后再拼接接口二的地址,与接口一的代码同理获取MP3链接。

MP3外链测试:

其他文章:
本文固定链接:https://www.hhtjim.com/ttpod-outside-chain-php-source-code.html
matrix
本文章由 matrix 于2014年03月30日发布在兼容并蓄, 零零星星分类下,目前没有通告,你可以至底部留下评论。
转载请注明:天天动听外链php源码-HHTjim'S 部落格
关键字:, , ,

有32 条评论 »

  1. 越读者 越读者 2015-3-23 20:59:17 +0800#18

    貌似不能用,原理理解了,可惜不懂代码。

  2. 天云网络 天云网络 2014-6-1 10:22:14 +0800#17

    飘过。。。

    • Matrix Matrix Moderator 2014-6-1 11:56:16 +0800

      好久不见 你的站没开?

  3. 灰常记忆 灰常记忆 2014-4-23 9:22:48 +0800#16

    我一直偷虾米的外链

    • Matrix Matrix Moderator 2014-4-23 14:17:56 +0800

      我也一样 现在就虾米的安逸

  4. 浪涛网 浪涛网 2014-4-17 9:15:16 +0800#15

    不错,非常需要这个

  5. 佳佳君 佳佳君 2014-4-13 17:16:05 +0800#14

    Po主专注外链500年

    • Matrix Matrix Moderator 2014-4-14 12:22:52 +0800

      哈哈 目前就抓外链还够本

  6. 小菜 小菜 2014-4-11 20:09:00 +0800#13

    有点麻烦的样子

    • Matrix Matrix Moderator 2014-4-14 12:25:05 +0800

      懒得搞的的话 用我那外链吧、 放在bae上的

  7. maillot trek maillot trek 2014-4-9 17:02:05 +0800#12

    空间网页游戏的歌

  8. 鬼少 鬼少 2014-4-7 21:44:52 +0800#11

    你这个CRC32代码 哪求的 虽然比我写的要复杂些, 不过能考虑到这样 还不错了 http://fm1314.duapp.com

    • Matrix Matrix Moderator 2014-4-8 12:38:49 +0800

      那CRC32()是在他的js里面找到的,具体点的我也忘了 没多余记录。

添加新评论 »

 🙈 😱 😂 😛 😭 😳 😀 😆 👿 😉 😯 😮 😕 😎 😐 😥 😡 😈 💡

插入图片

NOTICE: You should type some Chinese word (like “你好”) in your comment to pass the spam-check, thanks for your patience!