ShortUrl

跳转到: 导航, 搜索
(返回结果)
(json)
 
(未显示1个用户的2个中间版本)
第29行: 第29行:
 
<pre>
 
<pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
<shorturl>http://sinaurl.cn/h3rwE</shorturl>
+
<shorturl>http://sinaurl.cn/h5mh9</shorturl>
 
</pre>
 
</pre>
 +
 
====json====
 
====json====
 
<pre>
 
<pre>
第43行: 第44行:
 
<result>
 
<result>
 
   <url>
 
   <url>
     <url_short>http://sinaurl.cn/h3rwE</url_short>
+
     <url_short>http://sinaurl.cn/h5mh9</url_short>
     <url_long>http://v2ex.appspot.com/</url_long>
+
     <url_long>http://www.sina.com.cn</url_long>
 
     <type>0</type>
 
     <type>0</type>
 
   </url>
 
   </url>
第55行: 第56行:
 
     {
 
     {
 
         "type": 0,  
 
         "type": 0,  
         "url_long": "http://v2ex.appspot.com/",  
+
         "url_long": "http://www.sina.com.cn",  
         "url_short": "http://sinaurl.cn/h3rwE"
+
         "url_short": "http://sinaurl.cn/h5mh9"
 
     }
 
     }
 
]
 
]
 
</pre>
 
</pre>

2010年11月2日 (二) 09:47的最后版本

目录

shortUrl

转换url成短url。

URL

http://api.t.sina.com.cn/shortUrl.format

格式

xml, json

HTTP请求方式

GET

是否需要登录

true

请求数限制

false


请求参数

  • url 必选参数,需要转换的url
  • is_short 可选参数,默认为true,表示从长url转换成短url;false表示从短url转换成长url,true:1,false:0
  • is_batch 默认为false。true则使用批量方式,false使用单条方式,true:1,false:0。批量url用英文","分割

请求示例

返回结果(长链转短链)

xml

<?xml version="1.0" encoding="UTF-8"?>
<shorturl>http://sinaurl.cn/h5mh9</shorturl>

json

{
    "shorturl": "http://sinaurl.cn/h5mh9"
}

返回结果(短链转长链)

xml

<?xml version="1.0" encoding="UTF-8"?>
<result>
  <url>
    <url_short>http://sinaurl.cn/h5mh9</url_short>
    <url_long>http://www.sina.com.cn</url_long>
    <type>0</type>
  </url>
</result>

json

[
    {
        "type": 0, 
        "url_long": "http://www.sina.com.cn", 
        "url_short": "http://sinaurl.cn/h5mh9"
    }
]
文档更新时间: 2010-11-02