API 接口文档
快速集成题库搜索功能到您的应用
1
接口概述
接口地址
https://api2.gomooc.net/api.php
返回格式
JSON请求方式
GET
POST
请求示例
https://api2.gomooc.net/api.php ?token=xxx&question=问题&limit=5
请确保每项参数均不为空
2
参数说明
| 参数名 | 必填 | 类型 | 说明 |
|---|---|---|---|
token |
是 | string | 用户唯一token,在个人中心获取 |
question |
是 | string | 要搜索的问题关键词 |
limit |
否 | int | 返回的条数,不填默认为10 |
3
调用示例
const result = await fetch(
"https://api2.gomooc.net/api.php?token=" + token +
"&question=" + encodeURIComponent(question)
).then(r => r.json());
console.log(result.answer);
$token = "your_token_here";
$question = "问题";
$url = "https://api2.gomooc.net/api.php?" . http_build_query([
"token" => $token,
"question" => $question
]);
$response = file_get_contents($url);
$data = json_decode($response, true);
print_r($data);
import requests
token = "your_token_here"
question = "问题"
url = "https://api2.gomooc.net/api.php"
params = {"token": token, "question": question}
response = requests.get(url, params=params)
data = response.json()
print(data)