2019年9月16日将一个或多个长链接转换成短链接(功能已下线)
https://open.weibo.com/wiki/2/short_url/shorten什么玩意?新浪短网址API不开放了???
(不存在的)
咱们机智的网友惊奇的发现:
新浪的分享页面也就是:
https://service.weibo.com/share/share.php?url=网址&extra=page%3D1&title=标题可以生成短网址,于是机智套了个壳,就把它取出来了,亲测可行。
附上代码:
<?php$url=$_GET["url"];$data = http_get('https://service.weibo.com/share/share.php?url='.$url.'&extra=page%3D1&title=标题');preg_match_all('/<em class="tag_text">(.*)<\/em>/' , $data , $matches);print_r($matches[1][0]);function http_get($url){ $oCurl = curl_init(); if(stripos($url,"https://")!==FALSE){ curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1 } curl_setopt($oCurl, CURLOPT_URL, $url); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 ); $sContent = curl_exec($oCurl); $aStatus = curl_getinfo($oCurl); curl_close($oCurl); if(intval($aStatus["http_code"])==200){ return $sContent; }else{ return false; }}使用:
http://xxx.xx/x.php?url=
接下来就是开心的使用短网址,搞嘿嘿嘿了