| 接口地址 |
https://api.wq.cgdey.cn/API/today_food/today_food.php
|
|---|---|
| 请求方式 | GET |
| 返回格式 | JSON |
| 名称 | 必填 | 类型 | 描述 |
|---|---|---|---|
| - | 否 | - | 当前接口无需传参。 |
| 名称 | 类型 | 描述 |
|---|---|---|
| food | string | 返回的今日食物推荐名称。 |
| HTTP 状态 | 业务状态 | 说明 |
|---|---|---|
| 200 | success | 请求成功,已返回今天吃什么推荐。 |
| 503 | maintain | 接口临时维护中。 |
| 状态码 | 错误标识 | 说明 |
|---|---|---|
| 400 | bad_request | 请求格式错误或参数不符合要求。 |
| 429 | too_many_requests | 请求过于频繁,请稍后重试。 |
| 500 | server_error | 服务器内部异常,未正常返回内容。 |
<?php
echo file_get_contents('https://api.wq.cgdey.cn/API/today_food/today_food.php');
<?php
$ch = curl_init('https://api.wq.cgdey.cn/API/today_food/today_food.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['key' => 'value']));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import requests
response = requests.get('https://api.wq.cgdey.cn/API/today_food/today_food.php')
print(response.text)
import requests
response = requests.post(
'https://api.wq.cgdey.cn/API/today_food/today_food.php',
json={'key': 'value'}
)
print(response.text)
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.wq.cgdey.cn/API/today_food/today_food.php"))
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.wq.cgdey.cn/API/today_food/today_food.php"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{\"key\":\"value\"}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());