{"code":0,"msg":"ok","data":{"demo":"中文分词"}}
| 状态码 | 含义 | 常见原因与处理 |
|---|---|---|
| 200 | 正常返回 | 请求成功,按响应示例解析。 |
| 400 | 参数错误 | 必填参数缺失或格式不对,先按接口说明核对参数名。 |
| 401 | 未授权 | 缺少或写错了 KEY/Token,检查请求头。 |
| 403 | 禁止访问 | 来源域名不在白名单、额度用尽或接口已下线。 |
| 404 | 地址不存在 | 接口路径写错或已改版,以本页接口地址为准。 |
| 500 | 服务异常 | 对方服务器报错,稍后重试或去对方反馈渠道反馈。 |
JavaScript · fetch
var url = 'https://api.example.com/cut';
fetch(url, { method: 'POST' })
.then(function (r) { return r.json(); })
.then(function (d) { console.log(d); })
.catch(function (e) { console.error(e); });
PHP · cURL
$ch = curl_init('https://api.example.com/cut');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$body = curl_exec($ch);
curl_close($ch);
echo $body;
Python · requests
import requests
url = 'https://api.example.com/cut'
r = requests.request('POST', url, timeout=10)
print(r.status_code, r.text)
上一篇:短链接生成
下一篇:没有了
还没有人评论,占个楼吧~