5pv.cn是非常優(yōu)秀的短網(wǎng)址工具,能否分享、監(jiān)測(cè)您的鏈接,同時(shí)提供開放API接口。 API接口說明:http://www.5pv.cn/WebUser/ApiHelp 支持GET和POST方式。 以下示例是我通過POST方式結(jié)合Snoopy類進(jìn)行: function urlShort($urlLong = '') { $appkey='RUIyQ0U5NDNEREYzQzBC'; $secret='Q0ZFREQxQzIxRTA3NkQ5'; import('ORG.Net.Snoopy'); $sn=new Snoopy(); $data['appkey']=$appkey; $data['timestamp']=getMsec(); $data['sign']=md5($appkey . $secret . $data['timestamp']); $data['url'] = $urlLong; $sn->submit ('http://api.5pv.cn/5pvApi/Create',$data); $dwz = $sn->results; $dwz=str_replace('0','',$dwz); $dwz=preg_replace('/\s/','',$dwz); return 'http://5pv.cn/' . substr($dwz,3,strlen($dwz)); } /** * 得到當(dāng)前毫秒數(shù) * * @package controller * @author lixuanbin * @version 1.0 * @param null * @return null */ function getMsec() { list($usec, $sec) = explode(" ", microtime()); return (((float)$usec + (float)$sec)) * 1000; }
發(fā)表評(píng)論