尽管通过API添加联系人(POST /联系人)效果很好,但我并没有使用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
]);
}
我该如何解决?
答案 0 :(得分:0)
$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;
}