phpsdkcontactsinfusionsoft

how to get all infusionsoft contacts - PHP api?


Basically I just want to get all contacts of an app/account from Infusionsoft. I'm using PHP SDK from their documentation. Currently I can get contacts by using this:

$contacts = $infusionsoft->contacts()->all();

But this function is somewhat deceptive as it only returns 1000 records. What I wanted to do is get ALL contacts. We currently have over 10k+ contacts or even more. Any idea would greatly help. Thanks

I'm reading their documentation as well as the PHP-SDK sources but to no avail. I just want to have a way of iterating the contacts from Infusionsoft like some pagination of some sort. That would really help.


Solution

  • It is a little deceptive. It was built to mimic Laravel's Eloquent models however all the functionality wasn't implemented. You'll have to paginate manually.

    You can use something like the following:

    $contacts = [];
    $limit = 1000;
    $offset = 0;
    
    do {
    
    $results = $infusionsoft->contacts()->where('limit',$limit)->where('offset', $offset)->get();
    
    array_merge($contatcs, $results->toArray());
    
    $offset += $limit;
    
    } while (count($results->toArray()) == 1000);