php - 在 Active Collab API 中获取分页结果

标签 php api activecollab

我刚刚发现你可以通过 api 传递 page 参数来获取分页结果,如下所示:

$projects = $client->get('projects/147/time-records?page=3')->getJson();

有没有办法知道一个项目有多少时间记录,这样我就知道我需要分页多少次?

或者,我将如何检索几页有值(value)的数据 - 我正在为代码而苦苦挣扎!

最佳答案

我在 Github 上创建了一个问题- 将等待回复。

现在,我执行以下操作:

// Get all the projects

// Set the page number
$page = 1;

// Create an empty array
$project_records = array();

// Get the first page of results
$project_records_results = $client->get('projects?page=' . $page)->getJson();

// Merge the results with base array
$project_records = array_merge($project_records, $project_records_results);

// Get the next page of results, 
// if it returns something merge with the base array and continue
while ($project_records_results = $client->get('projects?page=' . ++$page)->getJson()) {
    $project_records = array_merge($project_records, $project_records_results);
}

关于php - 在 Active Collab API 中获取分页结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40020003/

相关文章:

php - Active Collab SSL 相关错误

php - 如何在地址栏中使用 utf8 url

ruby-on-rails - Rails --api 不起作用

php - 使用 php 和 magic quote 插入 HTML 代码

php - 如何为亚马逊 MWS 报告 API 设置报告类型

c# - 如何测试返回 Ok(new { token = tokenStr }); 的函数

python - 从 API 调用返回的 XML 中分配变量

activecollab - 如何使用 ActiveCollab API 通过全局 ID(无项目)访问任务

php - SELECT 查询计数未输出

php - 将数据从 .xml php 数组插入到 mysql