欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

获取新浪微博的Tiny网址链接

程序员文章站 2024-01-29 10:16:46
...
///////////////////////////////////////////////////////////////////////获取新浪微博的T网址链接
//http://open.weibo.com/wiki/2/short_url/shorten
//http://open.weibo.com/wiki/Help/error
//http://open.weibo.com/wiki/2/account/rate_limit_status 新版
///////////////////////////////////////////////////////////////////////获取新浪微博的T网址链接
//http://open.weibo.com/wiki/2/short_url/shorten
//http://open.weibo.com/wiki/Help/error
//http://open.weibo.com/wiki/2/account/rate_limit_status 新版
function GetTurl($url=''){

set_time_limit(0);
//$tApi="https://api.weibo.com/2/short_url/shorten.json?access_token=[你的token]&url_long=";
$tApi="https://api.weibo.com/2/short_url/shorten.json?source=[你的appkey]&url_long=";
$tApi=$tApi.urlencode($url);
$ret=file_get_contents($tApi);
$ret=json_decode($ret,true);
if($ret['error']) return $url;
if(is_array($ret['urls'])){
$r= $ret['urls'][0]['url_short'];
return $r;
}
return $url;

}

来自: http://www.55lm.net/

AD:真正免费,域名+虚机+企业邮箱=0元