php NetEase free short address interface
Release: 2016-07-25 09:06:42
Original
1376 people have browsed it
利用网易免费短地址接口开发的短网址缩短服务
演示地址:
http://3.tbip.sinaapp.com/
伪静态规则
RewriteEngine on
RewriteRule ^(.*)$ index.php?id=$1 [L]
define('REWRITE', '0'); //是否启用伪静态 1为启用0为不启用 define('IS_SINA', '0'); //是否sina sae 1为启用0为不启用 define('API_KEY', '2e409ff7a967418aa5e4dd15051702ba'); //API key请自行申请 $weburl=getenv('SERVER_NAME').dirname(getenv('SCRIPT_NAME')); $weblink=REWRITE?"http://".$weburl."/":"http://".$weburl."/?"; if($_GET['url']){ $data=duanurl($_GET['url']); $shorturls=str_replace('126.am/',$weblink,$data->url);
}else if(count($_GET)>0){
$headurl=getenv("QUERY_STRING");echo "<script>location.href='http://126.am/".$headurl."'</script>";
}
?>?
网易免费短地址
a:link {color:#666;}
a:visited {text-decoration: none;color: #333;}
a:hover {text-decoration: none; color: #333;}
a:active {text-decoration: none;color: #CCC;}
body{margin:0px;background:url(bg_body.jpg) repeat-x;height:100%;text-align: center;}
.warp{margin:0 auto;width:620px;}img{border:none;}.c{clear:both;}.l{float:left;}.r{float:right;}ul,li{list-style:none;}
.main{margin:0 auto;width:620px;}
.logo{margin:20px auto;text-align:center;}
.logo a{font-size:50px}
.main p{text-align:center;color:#999;font-size:14px;}
.area{padding:10px;background:#f1f7f8;border:1px solid #cfe0e0;}
.text_are{float:left;width:440px;height:36px;padding:5px 0;border:1px solid #c6c6c6;font-size:16px;background:#ffffe6;}
.text_btn{float:left;margin-top:-1px;width:86px;height:36px;border:1px solid #c6c6c6;background:#f8f8f8;}
.list{float:left;margin-top:-1px;padding:9px;border:1px solid #cfe0e0;background:#FFF;font-size:12px;color:#999;}
.list td{padding:3px 5px;border-bottom:1px solid #e1edef;height:30px;}
.more a{color:#333;text-decoration:none;}
.footer{margin-top:15px;font-size:11px;color:#CCC;text-align:center;}
<script>var bdShare_config = {"type":"large","color":"blue","uid":"533431","share":"yes"};</li>
<li>document.getElementById("bdlike_shell").src="http://bdimg.share.baidu.com/static/js/like_shell.js?t=" + new Date().getHours();</li>
<li></script>
function ob_gzip($content){ if(!headers_sent()&&extension_loaded("zlib")&&strstr($_SERVER["HTTP_ACCEPT_ENCODING"],"gzip")){ $content = gzencode($content,9); header("Content-Encoding: gzip"); header("Vary: Accept-Encoding"); header("Content-Length: ".strlen($content)); } return $content; } function duanurl($url) { if(IS_SINA){ $f = new SaeFetchurl(); $f->setMethod("post");
$f->setPostData(array("key"=>API_KEY,"longUrl"=>$url));
$content=$f->fetch("http://126.am/api!shorten.action");
if($f->errno() == 0) {
$return =$content;
}else{$return = $f->errmsg();}
}else{
$ch=curl_init();
curl_setopt_array(
$ch,
array(
CURLOPT_URL=>'http://126.am/api!shorten.action',
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_POST=>true,
CURLOPT_POSTFIELDS=>'key='.API_KEY.'&longUrl='.$url
));
$content=curl_exec($ch);
if(curl_errno($ch)) $return=curl_error($ch);
else $return=$content;
curl_close($ch);
}return json_decode($return);
}ob_end_flush(); ?>
复制代码
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
2024-10-22 09:46:29
2024-10-13 13:53:41
2024-10-12 12:15:51
2024-10-11 22:47:31
2024-10-11 19:36:51
2024-10-11 15:50:41
2024-10-11 15:07:41
2024-10-11 14:21:21
2024-10-11 12:59:11
2024-10-11 12:17:31