【发布时间】:2022-01-07 15:02:30
【问题描述】:
我是这个 Restful Api 的新手,我目前正在使用来自 Atera 的 Restful Api 到我的 MongoDB 数据库中。
这是来自 Atera Api 的示例
{
"items": [
{
"AlertID": xxxx,
"Code": xxxx,
"Source": "string",
"Title": "string",
"Severity": "Information",
"Created": "2021-12-01T01:09:52.888Z",
"SnoozedEndDate": "2021-12-01T01:09:52.888Z",
"DeviceGuid": "string",
"AdditionalInfo": "string",
"Archived": true,
"AlertCategoryID": "Hardware",
"ArchivedDate": "2021-12-01T01:09:52.888Z",
"TicketID": xxxx,
"AlertMessage": "string",
"DeviceName": "string",
"CustomerID": xxxx,
"CustomerName": "string",
"FolderID": xxxx,
"PollingCyclesCount": 0
}
],
"totalItemCount": 6783,
"page": 1,
"itemsInPage": 20,
"totalPages": 290,
"prevLink": "",
"nextLink": "http://app.atera.com/api/v3/alerts?page=2&itemsInPage=20"
}
这将是我使用 Guzzle 获取 Api 的代码
$client = new Client();
$uri = 'https://app.atera.com/api/v3/alerts';
$header = ['headers' => ['X-Api-Key' => 'xxxxxxx']];
$res = $client->get($uri, $header);
$data = json_decode($res->getBody()->getContents(), true);
如您所见,我正在使用 Guzzle 来获取此内容,但不知何故,我最多只能获取 20 个项目,但我可以看到它限制了每页的项目数,即每页 20 个项目,但我想获取所有信息,我有 6000 多个警报项。
我尝试过的 Fetch...
获取警报?items=6000
获取警报?itemsInPage=6000
获取警报?itemsInPage[大小]=6000
获取警报?limit=6000
获取警报?top=6000
获取警报?count=6000
获取警报?size=6000
获取警报?offset=6000
获取警报?limit=6000&offset=0
获取警报?limit=6000&offset=6000
获取警报?sysparm_limit=10000&sysparm_offset=10000
还有更多...
不过,我最多只能获得 20 个,有没有办法一次获取所有内容?
【问题讨论】: