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优化及高效提速问题的实现方法第1/2页

一、 在函数中,传递数组时使用 return 比使用 global 要高效,比如: function userloginfo($usertemp){ $detail=explode("|...

有关JSON以及JSON在PHP中的应用

JSON 基础 简 单地说,JSON 可以将 JavaScript 对象中表示的一组数据转换为字符串,然后就可以在函数之间轻松地传递这个字符串,或者在异步应用程序中将字符串从 Web 客...

PHP filesize函数用法浅析

filesize() 函数返回指定文件的大小。 若成功,则返回文件大小的字节数。若失败,则返回 false 并生成一条 E_WARNING 级的错误。 php filesize()函数...

PHP中的cookie不用刷新就生效的方法

不过,这种机制总是会给我们带来这或那的问题,比如前段时间,我的站点上得设置一个广告显示的功能,就需要用到COOKIE,主要目的是为了加大广告的转化率,可是如果刷新生效,就比较麻烦,所以就...

php检测apache mod_rewrite模块是否安装的方法

本文实例讲述了php检测apache mod_rewrite模块是否安装的方法。分享给大家供大家参考。具体实现方法如下: /** * @title Check if Apache'...