新浪短连接接口
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 }
版权声明:本文为cuculus原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。