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设计模式 Facade(外观模式)

php设计模式 Facade(外观模式)

模式定义:外观模式(Facade Pattern):外部与一个子系统的通信必须通过一个统一的外观对象进行,为子系统中的一组接口提供一个一致的界面,外观模式定义了一个高层接口,这个接口使得...

php提示Failed to write session data错误的解决方法

本文较为详细的分析了php提示Failed to write session data错误的解决方法。分享给大家供大家参考。具体方法如下: 一、问题: 提示信息:Warning: Fai...

php文件操作之文件写入字符串、数组的方法分析

php文件操作之文件写入字符串、数组的方法分析

本文实例讲述了php文件操作之文件写入字符串、数组的方法。分享给大家供大家参考,具体如下: 场景一:用文本文档记录一些操作日志,因为对于一些频繁的操作,操作记录的数据量势必会很大,...

mac pecl 安装php7.1扩展教程

鉴于brew突然间的不能使用,简直是好坑的,以前多方便的安装啊,现在却那啥,好尴尬啊 brew search php ==> Searching local taps... p...

解决File size limit exceeded 错误的方法

昨日遇到一个问题,使用Yii框架编写php脚本,将db中100多万的数据导出,运行,成功。 但是在 运行到第 49万条时,脚本终止,提示错误“File size limit exceed...