新浪短连接接口

 1      public function short_linkAction()
 2         {
 3             $url = Request::getPost('url');
 4 
 5             $return = array('url'=> $url);
 6 
 7             //新浪短网址
 8             $new_url = 'http://api.weibo.com/2/short_url/shorten.json?source=3235337692&url_long='.rawurlencode( $url );
 9             $text = Request::fetch( $new_url );
10             $data = json_decode($text, true);
11     
12             if( isset( $data['urls'] ) )
13             {
14                 $short_url = $data['urls'][0]['url_short'];
15                 $return['short_url'] = $short_url;
16             }
17 
18             return $return;
19         }

 

posted @ 2017-11-14 15:31  cuculus  阅读(1319)  评论(1编辑  收藏  举报