可以把长网址缩短为短网址。
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| key | string | 是 | 接口调用密钥 | |
| url | string | 是 | 需要缩短的网址 | api.317ak.com |
[
{
"name": "key",
"type": "string",
"required": true,
"description": "接口调用密钥",
"example": ""
},
{
"name": "url",
"type": "string",
"required": true,
"description": "需要缩短的网址",
"example": "api.317ak.com"
}
]
{
"openapi": "3.1.1",
"info": {
"title": "短网址生成",
"description": "可以把长网址缩短为短网址。",
"version": "1.0.0"
},
"paths": {
"/api/zzgj/dwz/api.php": {
"get": {
"summary": "短网址生成",
"description": "可以把长网址缩短为短网址。",
"parameters": [
{
"name": "key",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "接口调用密钥"
},
{
"name": "url",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "api.317ak.com"
},
"description": "需要缩短的网址"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
},
"post": {
"summary": "短网址生成",
"description": "可以把长网址缩短为短网址。",
"parameters": [
{
"name": "key",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "接口调用密钥"
},
{
"name": "url",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "api.317ak.com"
},
"description": "需要缩短的网址"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://api-v2.317ak.com",
"description": "当前访问入口(https)"
}
]
}
{
"code": 1000,
"data": {
"url": "http://i71i.com/c1t8"
}
}
该接口用于将较长的网址转换为更简洁的短网址。适用于站长工具场景,方便开发者或网站运营人员进行网址缩短处理。
https://api-v2.317ak.com/api/zzgj/dwz/api.php
GET、POST
调用接口需要提供密钥,采用 Query 方式鉴权。
请求时在参数中传入 key,格式为 key=接口调用密钥。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| key | string | 是 | 接口调用密钥,通过 Query 参数传递。 |
| url | string | 是 | 需要缩短的网址,例如:api.317ak.com。 |
{
"code": 1000,
"data": {
"url": "http://i71i.com/c1t8"
}
}
| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 响应状态标识,1000 表示请求成功 |
| data | object | 成功返回的数据对象 |
| data.url | string | 生成后的短网址 |
当接口请求失败时,返回错误信息示例:
{"code":0,"msg":"未提供调用密钥","errcode":11001}
| errcode | 含义 |
|---|---|
| 11001 | 未提供调用密钥 |
| 11002 | 密钥错误 |
| 11003 | 密钥已禁用 |
| 11004 | 积分余额不足 |
| 11005 | 请求过于频繁(QPM 限制) |
| 11006 | 接口维护中 |
| 11007 | 接口已禁用 |
| 11008 | 接口不可用 |
| 11009 | 密钥校验暂不可用 |
| 11010 | 积分系统暂不可用 |
| 11011 | 收费接口须提供有效密钥 |
| 11012 | 鉴权方式错误 |
| 11013 | 接口不存在 |
| 11014 | ***地址无效 |
| 11015 | ***地址不允许 |
| 11016 | ***请求失败 |
| 11017 | 服务暂不可用 |
| 11018 | 请求方式不允许 |
| 11019 | 当前IP不在白名单内 |
| 11020 | 启用出口代理须提供有效密钥 |
| 11021 | 未配置可用出口代理 |
| 11022 | 出口代理不可用 |
| 11023 | 密钥已过期 |
| 11024 | 令牌分配积分不足 |
请求方式为 GET,密钥通过 Query 参数传递。
curl "https://api-v2.317ak.com/api/zzgj/dwz/api.php?key=YOUR_KEY&url=api.317ak.com"
// PHP
$url = 'https://api-v2.317ak.com/api/zzgj/dwz/api.php?key=YOUR_KEY&url=api.317ak.com';
$result = file_get_contents($url);
echo $result;
key,避免将密钥公开发布、提交到公开代码仓库或暴露在不受信任的环境中。key 参数填写正确,否则可能导致接口调用失败。url 参数必须传入有效的网址内容,建议包含完整的网址格式,避免因参数格式错误导致生成失败。curl -G 'https://api-v2.317ak.com/api/zzgj/dwz/api.php' \
--data-urlencode 'key=YOUR_API_KEY' \
--data-urlencode 'url=api.317ak.com'