PHP implements short URL open source API without database_PHP tutorial

WBOY
Release: 2016-07-13 17:53:16
Original
939 people have browsed it

[php]
Configuration file
[php]
/*Website settings*/
define(SITE,"http://xxx.com");//Do not add / after the domain name
/*API settings*/
define(API_KEY,"");//API, application address: http://qita.in/reg.php
/*Advanced Settings*/
define(OPEN_AD,"0");//Jump page advertising switch, 1 means on, 0 means off.
define(AD,"I am an advertisement");//Ad content, the content in double quotes must only contain single quotes
define(TIME,"3");//Jump waiting time
?>


Main code


[php] 
require_once('config.inc.php');
if(API_KEY==""){
echo "请修改config.inc.php API_KEY参数,点击注册申请API"; 

if(count($_GET['url'])>0){ 
//$url = "http://1dnet.net/index.php?api=1&return_url_text=1&longUrl=".$_GET['url'];  
$url="http://qita.in/app.php?api=".API_KEY."&type=noad&url=".$_GET['url'];  
$ch = curl_init();  
$timeout = 5;  
curl_setopt($ch, CURLOPT_URL, $url);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);  
//在需要用户检测的网页里需要增加下面两行  
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);  
//curl_setopt($ch, CURLOPT_USERPWD, US_NAME.":".US_PWD);  
$contents = curl_exec($ch);  
eregi('http://qita.in/(.*)',$contents,$new); 
curl_close($ch);  
if(strlen($contents)<8){
$shorturl="请输入正确的短网址";
}
$shorturl=SITE."/$new[1]";
//echo "[统计]"; 
//echo '';  

?> 
 
 
 
 
7898.org免费短地址 
 
 
 
 
 
 

 
 
      
       

缩短、分享及监测你的链接 

 
       
 
           
 
               
 
                 
 
               
 
               
 
           
 
           
 
                     
                         
     
     
 
 
'; 
echo ''; 
?> 
 
       
短链接原始网址
 
echo ''.$shorturl.'
'.$_GET['url'].'
 
         
 
           
 
  
           
 
       
 
 
  
 
 
 
 
 
 

 作者:liangxunli

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478059.htmlTechArticle[php] 配置文件 [php] ?php /*网址设置*/ define(SITE,http://xxx.com);//域名后面不要加/ /*API设置*/ define(API_KEY,);//API,申请地址:http://qita.in/reg.php /*高级...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template