GetResponse API v3:GET /contacts 不 return 所有联系人
GetResponse API v3: GET /contacts does not return all 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;
}
虽然通过 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;
}