5 Star 37 Fork 12

BWmelon / qrcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
long2tiny.php 884 Bytes
一键复制 编辑 原始数据 按行查看 历史
BWmelon 提交于 2020-09-13 21:44 . :pencil:readme
<?php
// 例:
// 短网址接口为:https://url.xxx.cn/api.php?url=
// 成功时返回格式为:
// {
// code: 0, // 状态码
// data: {
// long_url: 'https://qr.xxx.cn/allqr.html?xxxxxxxxxxxxx', // 原长网址
// short_url: 'https://url.xxx.cn/xxxxx' // 生成的短网址
// }
// }
if ($_GET['url_long']) {
$url_long = $_GET['url_long'];
} else {
echo "Longurl can not be empty.";
return;
}
$api = "https://url.xxx.cn/api.php?url="; // 此处填写短网址接口
// 请求地址
$url = $api . $url_long;
$res = json_decode(file_get_contents($url), true);
if($res["code"] == 0) { // 此处填写生成成功时接口返回状态值和状态码
$tinyurl = $res["data"]["short_url"]; // 此处填写短网址所在的路径
} else {
$tinyurl = $url_long; // 生成失败则默认使用原来的长网址
}
echo $tinyurl;
HTML
1
https://gitee.com/BWmelon/qrcode.git
git@gitee.com:BWmelon/qrcode.git
BWmelon
qrcode
qrcode
master

搜索帮助