PHP开发实例大全(提高卷) 中文完整pdf扫描版[244MB]
<?php
function getShortUrl($showUrl){
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,"http://dwz.cn/create.php");
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$data=array('url'=>$showUrl);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$strRes=curl_exec($ch);
curl_close($ch);
$arrResponse=json_decode($strRes,true);
if($arrResponse['status']==0)
{
/**错误处理*/
echo iconv('UTF-8','GBK',$arrResponse['err_msg'])."\n";
}
/** tinyurl */
return $arrResponse['tinyurl']."\n";
}
//使用方法
//使用方法
echo getShortUrl("http://www.kuitao8.com");
echo "<br/>";
echo getShortUrl('http://www.kuitao8.com/20131002/1486.shtml');
?>
转载请注明:谷谷点程序 » php生成短网址的代码