GetResponse API v3:GET /contacts 不会返回所有联系人



虽然通过 API 添加联系人(POST/contacts)工作正常,但我无法使用 GET/contacts 获得所有活动联系人(请参阅 https://apidocs.getresponse.com/v3/resources/contacts)。

public function getContacts()
{
    return $this->get('contacts', [
        'query' => [
            'campaignId' => $this->campaign
        ],
        'fields' => 'name,email',
        'perPage' => $this->perPage
    ]);
}

我该如何解决它?

$perPage限制为 1000:

public function getContacts($page = 1)
{
    return $this->get('contacts', [
        'query' => [
            'campaignId' => $this->campaign
        ],
        'fields' => 'name,email',
        'sort' => [
            'createdOn' => 'desc'
        ],
        'perPage' => $this->perPage, // max. 1000
        'page' => $page
    ]);
}
public function getAllContacts()
{
    $page = 1;
    $allContacts = [];
    while ($contacts = $this->getContacts($page++)) {
        array_push($allContacts, ...$contacts);
    }
    return $allContacts;
}

最新更新