好友
阅读权限10
听众
最后登录1970-1-1
|
本帖最后由 航航Winter 于 2020-9-21 20:25 编辑
具体接口'tcn','urlcn','t360','sinaurl','wurl','mrw','suoim','suonz','unu','gitio','surl','vurl','zz3','syam'
不会PHP的可以http://dwz.nyun.cc/这里生成
短网址问题反馈https://vurl.video.qq.com/FOoYYmfs
[PHP] 纯文本查看 复制代码 <?php
header("Content-Type:text/json; charset=utf-8");
$dwzapiall = array('tcn','urlcn','t360','sinaurl','wurl','mrw','suoim','suonz','unu','gitio','surl','vurl','zz3','syam');
$longurl = (isset($_GET['url'])) ?$_GET['url']:$_POST['url'];
$dwzapi = (isset($_GET['dwzapi'])) ?$_GET['dwzapi']:$_POST['dwzapi'];
if(!$longurl||!$dwzapi){
exit (returnMsg(-1, "生成失败", '参数不完整'));
}else if(strpos($longurl,".") == false){
exit (returnMsg(-1, "生成失败", 'URL格式错误'));
}if (!preg_match('/^http[s]?:\\/\\//', $longurl)) {
$longurl = "http://" . $longurl;
return true;
}
if (in_array($dwzapi, $dwzapiall)) {
$dwzurl = dwz($longurl,$dwzapi);
if($dwzurl){exit (returnMsg(0, "生成成功", $dwzurl));
}else{exit (returnMsg(-1, "生成失败", '接口生成失败'));}
}else{exit (returnMsg(-1, "生成失败", '短网址参数错误'));}
function dwz($longurl,$dwzapi)
{
$url = 'http://api.nyun.cc/dwz/index.php?url='.urlencode($longurl).'&dwzapi='.$dwzapi;
$result = curl($url);
$arr = json_decode($result, true);
$result = $arr['data'];
if (!$result) {
} else {
return $result;
}
}
function returnMsg($code, $msg, $data)
{
return json_encode(['code'=>$code, 'msg'=>$msg, 'data'=>$data], JSON_UNESCAPED_UNICODE);
}
function curl($url, $method='GET', $params=array(), $getinfo=false)
{
$header = array();
if(isset($params["header"])){
$header = array_merge($header,$params["header"]);
}
$user_agent = empty($params["ua"]) ? 0 : $params["ua"] ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if($params["ref"]){
curl_setopt($ch, CURLOPT_REFERER, $params["ref"]);
}
if (array_key_exists('responseHeader', $params) && $params['responseHeader']) {
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
}else {
curl_setopt($ch, CURLOPT_NOBODY, false);
}
curl_setopt($ch, CURLOPT_USERAGENT,$user_agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 3600);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_ENCODING, '');
if($method == 'POST'){
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params["postData"]);
}
$res = curl_exec($ch);
if ($getinfo) {
$data = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
}else {
$data = $res;
}
curl_close($ch);
return $data;
}
?> |
免费评分
-
查看全部评分
|