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生成rss类用法实例

本文实例讲述了php生成rss类用法,分享给大家供大家参考。具体如下: <?php require('rssbuilder.class.php'); header('C...

解析php获取字符串的编码格式的方法(函数)

如果不清楚字符串的编码格式的话,就可以将这段字符这样检查:$encode = mb_detect_encoding($string, array("ASCII",'UTF-8′,"GB2...

PHP5.3安装Zend Guard Loader图文教程

PHP5.3安装Zend Guard Loader图文教程

Zend Optimizer/3.3.3 解密加代码优化,提高PHP应用程序的执行速度,显著降低服务器的CPU负载。 Zend Guard Loader/5.5.0/6.0 解密加代码优...

关于PHP自动判断字符集并转码的详解

原理很简单,因为gb2312/gbk是中文两字节,这两个字节是有取值范围的,而utf-8中汉字是三字节,同样每个字节也有取值范围。而英文不 管在何种编码情况下,都是小于128,只占用一个...

php-fpm.conf配置文件中文说明详解及重要参数说明

php-fpm.conf配置文件中文说明详解及重要参数说明

php-fpm工作流程 php-fpm全名是PHP FastCGI进程管理器 php-fpm启动后会先读php.ini,然后再读相应的conf配置文件,conf配置可以覆盖php.ini...