最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php调用新浪微博短链接api接口地址例子
时间:2022-06-24 22:46:04 编辑:袖梨 来源:一聚教程网
新浪短网址接口的稳定性和跳转速度还是很给力的,现给出其API说明。
该接口支持两种返回格式:xml和json
对应的URL请求地址为:
代码如下 | 复制代码 |
xml:http://api.t.sina.com.cn/short_url/shorten.xml |
使用说明
请求方式:GET
请求参数:
source:应用的appkey
url_long:需要转换的长链接
举个例子:
代码如下 | 复制代码 |
xml:http://api.t.sina.com.cn/short_url/shorten.xml?source=123456789&url_long==https://www.111com.net 返回内容为:
json:http://api.t.sina.com.cn/short_url/shorten.json?source=123456789&url_long=https://www.111com.net |
返回内容为:
[{"url_short":"http://t.cn/123456789","url_long":https://www.111com.net","type":0}]
代码如下 | 复制代码 |
session_start(); |
php原始做法
代码如下 | 复制代码 |
#短连接生成算法 public static function short($url) { #将加密后的串分成4段,每段4字节,对每段进行计算,一共可以生成四组短连接 $short_url = "http://t.cn/"; $short_url_list[] = $short_url; return $short_url_list; $url = http://www.111com.net; ******************************** |
调用方法:
代码如下 | 复制代码 |
$short = Short_Url::short('www.baidu.com'); |
相关文章
- 《职场浮生记》卡牌模组推荐 06-15
- 《纸嫁衣4红丝缠》全章节图文攻略 06-15
- 《这城有良田》奖率三军课业加点攻略 06-15
- 《纸嫁衣2奘铃村》全章节攻略汇总 06-15
- 《王者荣耀》夺宝保底次数介绍 06-15
- 《向僵尸开炮》百分比宝石选择推荐 06-15