cURL 复制
curl -X POST "https://cx4.cn/openApi/content/riddle" -H "X-Api-Key: 你的SecretKey" -d "difficulty=2&with_answer=1&count=3"
JavaScript 复制
fetch('https://cx4.cn/openApi/content/riddle', {
method: 'POST',
headers: {
'X-Api-Key': '你的SecretKey',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'difficulty=2&with_answer=1&count=3'
})
.then(res => res.json())
.then(data => console.log(data));
PHP 复制
<?php
require 'vendor/autoload.php';
$client = new \GuzzleHttp\Client();
$response = $client->post('https://cx4.cn/openApi/content/riddle', [
'headers' => ['X-Api-Key' => '你的SecretKey'],
'form_params' => ['difficulty' => '2', 'with_answer' => '1', 'count' => '3'],
]);
echo $response->getBody();
Java 复制
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://cx4.cn/openApi/content/riddle"))
.header("X-Api-Key", "你的SecretKey")
.header("Content-Type", "application/x-www-form-urlencoded")
.POST(HttpRequest.BodyPublishers.ofString("difficulty=2&with_answer=1&count=3"))
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Python 复制
import requests
res = requests.post('https://cx4.cn/openApi/content/riddle',
headers={'X-Api-Key': '你的SecretKey'},
data={'difficulty': '2', 'with_answer': '1', 'count': '3'})
print(res.json())