本帖最后由 无名小银 于 2019-9-16 15:07 编辑
鉴于官方接口下下,特奉献我自己的t.cn网址缩短源码[PHP] 纯文本查看 复制代码 <?php
function weibo_url($site){
$url = 'http://service.weibo.com/share/share.php?url='.urlencode($site).'&title=ířÖˇťńČĄ&pic=&appkey=';
set_time_limit(0);
sleep(0.5);
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_REFERER, "http://news.cctv.com/2019/04/02/ARTIFR5qnxs1fj0v7j3CqXPI190402.shtml");
curl_setopt($ch, CURLOPT_MAXREDIRS,3);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
curl_close($ch);
preg_match('#<em class="tag_text">(.*?)<\/em>#' , $result ,$wburl);
return json_encode(['result'=>'ok','url'=>$site,'wb_url'=>$wburl[1],'time'=>time()]);
}
print_r(weibo_url($_GET['url'])); |