t.cn网址缩短PHP源码

180it 2019-10-30 PM 2060℃ 0条

<?php
function weibo_url($site){

    $url = 'http://service.weibo.com/share/share.php?url='.urlencode($site).'&title=í&#345;&#214;ˇ&#357;ń&#268;&#260;&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']));

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

t.cn网址缩短PHP源码