最新下载
热门教程
- 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.si*n*a.*com.cn/short_url/shorten.xml |
使用说明
请求方式:GET
请求参数:
source:应用的appkey
url_long:需要转换的长链接
举个例子:
代码如下 | 复制代码 |
xml:http://api.t.si*n*a.*com.cn/short_url/shorten.xml?source=123456789&url_long==https://www.111com.net 返回内容为:
json:http://api.*t.*s*ina.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.*c*n*/"; $short_url_list[] = $short_url; return $short_url_list; $url = https://www.111cn.net; ******************************** |
调用方法:
代码如下 | 复制代码 |
$short = Short_Url::short('www.baidu.com'); |
相关文章
- 逆战未来随风之锤性能怎么样 09-18
- 忘川风华录萧绰如何培养 09-18
- 魔兽世界沙塔斯城传送门在哪-沙塔斯城传送门位置分享 09-18
- 为了吾王遗失的补给位置在哪里 09-18
- 魔法工艺次元行者太阳有什么玩法技巧 09-18
- 新三国志曹操传魏国三星武将怎么选择 09-18