名称 | 必填 | 类型 | 说明 |
---|---|---|---|
type | 是 | string | 请求类型【json、js】 |
名称 | 类型 | 说明 |
---|---|---|
code | integer | 返回的状态码 |
data | object | 返回的数据/数据对象 |
msg | string | 返回的消息 |
time | string | 请求时间 |
{
"code": 200,
"data": "你不勇敢,没人替你坚强!",
"msg": "请求成功!",
"time": "2024-11-00 10:06:54"
}
名称 | 类型 | 说明 |
---|---|---|
200 | string | 返回状态码(成功) |
500 | string | 返回状态码(失败,未输入请求参数) |
501 | string | 返回状态码(失败,请求参数输入有误) |
<?php
// 初始化cURL会话
$ch = curl_init();
// 设置请求URL,用户中心获取token,自行替换其他参数
curl_setopt($ch, CURLOPT_URL, "https://api.ba9.cn/api/get.yiyan?type=json ");
// 设置请求头
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: YOUR_TOKEN'
));
// 返回响应而不是直接输出
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 执行请求并获取响应
$response = curl_exec($ch);
// 关闭cURL会话
curl_close($ch);
// 将响应解析为JSON格式
$data = json_decode($response, true);
// 输出JSON数据
print_r($data);
?>
暂无示例
暂无示例
暂无示例
暂无示例
暂无示例
暂无示例