【问题标题】:ZohoCRM Module getRecords PHPZohoCRM 模块 getRecords PHP
【发布时间】:2020-10-28 05:58:56
【问题描述】:

我正在使用 ZohoCRM PHP SDK 尝试从 CRM 中提取所有 Account 记录并在本地操作它们(做一些报告)。基本代码如下所示,运行良好:

    $account_module = ZCRMModule::getInstance('Accounts');
    $response = $account_module->getRecords();
    $records = $response->getData();

    foreach ($records as $record) {
        // do stuff
    }

问题是$records 对象只有 200 条记录(总共约 3000 条)。我在(最少/很少记录的)SDK 文档中找不到任何文档,显示如何分页或获得更大的结果集,并且开发站点中的 Zoho 代码示例似乎由于某种原因没有使用相同的 SDK。

有人知道我如何对这些记录进行分页吗?

【问题讨论】:

    标签: php zoho


    【解决方案1】:

    getRecords()method seems to accept 2 个参数。这在某些their examples 中使用。您应该能够使用这些参数来设置/控制分页。

    $param_map = ["page" => "20", "per_page" => "200"];
    $response = $account_module->getRecords($param_map);
    

    【讨论】:

      【解决方案2】:

      @dakdad 是正确的,您可以将页面和每页值传递到param_map。您还应该使用$response->getInfo()->getMoreRecords() 来确定是否需要分页。像这样的东西似乎有效:

      $account_module = ZCRMModule::getInstance('Accounts');
      $page = 1;
      $has_more = true;
      
      while ($has_more) {
          $param_map = ["page" => $page, "per_page" => "200"];
          $response = $account_module->getRecords($param_map);
          $has_more = $response->getInfo()->getMoreRecords();
      
          $records = $response->getData();
          foreach ($records as $record) {
              // do stuff
          }
          $page++;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-02-17
        • 1970-01-01
        • 1970-01-01
        • 2023-03-29
        • 1970-01-01
        • 2013-11-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多