## 短网址生成接口
需要密钥联系QQ1457751117(注明来意)
请求参数(Body)
| 字段 | 类型 | 是否必须 | 说明 |
| --- | --- | --- | --- |
| token | string | 必须 | 由数字和字母组成的32位字符 |
| longurl | string | 必须 | 要缩短的长网址 |
| format | string | 否 | 调用格式,值为json/text/jsonp或不传,不传时返回数据为json |
* PHP
* JavaScript
~~~
PHP演示代码<?php $geturl = 'http://9ww.net/api/create'; $param = http_build_query([ 'token' => '你的Token' ,'longurl' => '你的长网址' ,'format' => 'text' ]); $opts = [ 'http' => array( 'method' => "POST", 'header' => "Content-type: application/x-www-form-urlencoded\r\n". "Content-length:".strlen($param)."\r\n" . "Cookie: foo=bar\r\n" . "\r\n", 'content' => $param, ), "ssl" => array( "verify_peer" => false, "verify_peer_name" => false, ) ]; $dwz = file_get_contents($geturl, $param, stream_context_create($opts)); echo $dwz;?>
~~~
返回参数(Body)
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| code | string | 处理结果:'1'代表成功 |
| msg | string | 返回描述 |
| short | string | 生成的短链接,如果生成失败,则返回空 |
请求示例
| TEXT 格式 |
| --- |
| 请求:http://9ww.net/api/create?format=text&token=(联系客服索要)&longurl=urlencode('http://www.baidu.com') |
| 返回:http://9ww.net//1c |
| JSON 格式 |
| --- |
| 请求:http://9ww.net/api/create?format=json&token=(联系客服索要)&longurl=urlencode('http://www.baidu.com') |
| 返回:{"code":1,"type":"url","longurl":"http://www.baidu.com","short":"http://9ww.net/1f","date":"03-10-2020 12:32:25"} |
| JSONP 格式 |
| --- |
| 请求:http://9ww.net/api/create?format=jsonp&callback=callbackname&token=(联系客服索要)&longurl=urlencode('http://www.baidu.com') |
| 返回:callbackname({"code":1,"type":"url","longurl":"http://www.baidu.com","short":"http://9ww.net/1f","date":"03-10-2020 12:33:08"}) |
## 短网址还原接口
请求参数(Body)
| 字段 | 类型 | 是否必须 | 说明 |
| --- | --- | --- | --- |
| dwz | string | 必须 | 由数字和字母组成的32位字符 |
| format | string | 否 | 调用格式,值为json/text/jsonp或不传,不传时返回数据为json |
返回参数(Body)
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| code | string | 处理结果:'1'代表成功 |
| msg | string | 返回描述 |
| short | string | 还原的长链接,如果还原失败,则返回空 |
请求示例
| TEXT 格式 |
| --- |
| 请求:http://9ww.net/api/query?format=text&dwz=http://9ww.net/d |
| 返回:http://www.pc.com |
| JSON 格式 |
| --- |
| 请求:http://9ww.net/api/query?format=json&dwz=http://9ww.net/d
|
| 返回:{"code":"1","longurl":"http://www.pc.com","short":"http://9ww.net/d"} |
| JSONP 格式 |
| --- |
| 请求:http://9ww.net/api/query?format=jsonp&callback=callbackname&dwz=http://9ww.net/d
|
| 返回:callbackname({"code":"1","longurl":"http://www.pc.com","short":"http://9ww.net/d"}) |