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


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

标签: 函数

相关文章

阿里云的WindowsServer2016上部署php+apache

阿里云的WindowsServer2016上部署php+apache

一、说明:项目需要在阿里云的WindowsServer2016上部署web环境,已经安装了Mysql,所以就不用一键安装(如phpstudy或者wamp来安装web环境了),就独立安装了...

php简单实现数组分页的方法

本文实例讲述了php简单实现数组分页的方法。分享给大家供大家参考,具体如下: 首先学东西  要多看手册 用php自带的函数  可以解决一些难解的问题 <&#...

PHP 使用header函数设置HTTP头的示例解析 表头

如下所示:复制代码 代码如下://定义编码  header( 'Content-Type:text/html;charset=utf-8 ');  //Atom&nb...

sae使用smarty模板的方法

Smarty是非常流行的模板系统,它分离了业务和逻辑、执行速度快,在php网站中有广泛的运用。 不过在部署到sina app engine(sae)上时出现了问题,因为sae作为云计算平...

基于php编程规范(详解)

今天写这个是为了 提醒自己 编程过程 不仅要有逻辑 思想 还有要规范 代码 这样可读性 1、PHP 编程规范与编码习惯最主要的有以下几点:  1 文件说明  2 fu...