php 网址url转迅雷thunder资源下载地址的方法函数

yipeiwu_com6年前PHP代码库

其实迅雷的地址就是:

原url前面带AA,

后面带ZZ之后再base64_encode编码即可

即:  thunder:// + base64_encode("AA" + 原url + ZZ")

具体函数如下:

/**
 * 将链接转成迅雷下载链接
 * @param $url  文件链接
 * @param string $type  encode 编码 decode 解码
 * @return bool|string
 */
function Thunder($url, $type='encode') {
    if($type =='encode'){
        return "thunder://".base64_encode("AA".$url."ZZ");
    }else{
        return substr(base64_decode(substr(trim($url),10)),2,-2);
    }
}

网址url转迅雷调用示例:

/**
 * Url 转 迅雷
 */
$downloadUrl = 'http://v.yipeiwu.com';
$type = 'encode';
$thunderUrl = Thunder($downloadUrl,$type);
echo $thunderUrl;
//将输出 thunder://QUFodHRwOi8vdi55aXBlaXd1LmNvbVpa

迅雷转真实网址url调用示例

/**
 * 迅雷转Url
 */
$thunderUrl = 'thunder://QUFodHRwOi8vdi55aXBlaXd1LmNvbVpa';
$type = 'decode';
$downloadUrl = Thunder($thunderUrl,$type);
echo $downloadUrl;
//将输出 http://v.yipeiwu.com


希望以上内容对您有所帮助

标签: 函数

相关文章

php实现四舍五入的方法小结

本文实例总结了php实现四舍五入的方法。分享给大家供大家参考。具体分析如下: php实现四舍五入的三种方法,分别通过number_format函数、round函数和sprintf格式化输...

PHP针对redis常用操作实例详解

本文实例讲述了PHP针对redis常用操作。分享给大家供大家参考,具体如下: /*1.Connection*/ $redis = new Redis(); $redis->co...

mcrypt启用 加密以及解密过程详细解析

Mcrypt扩展库可以实现加密解密功能,就是既能将明文加密,也可以密文还原。 1.PHP加密扩展库Mcrypt安装在标准的PHP安装过程中并没有把Mrcypt安装上,但PHP的主目录下包...

PHP连接sql server 2005环境配置及问题解决

一、Windows下PHP连接SQLServer 2005 设定:安装的Windows操作系统(Win7 或XP均可,其他系统暂未测试),在C盘下;PHP的相关文件位于c:/PHP下面,...

PHP中preg_match函数正则匹配的字符串长度问题

项目中,用preg_match正则提取目标内容,死活有问题,代码测得死去活来。 后来怀疑PHP 的preg_match有字符串长度限制,果然,发现“pcre.backtrack_limi...