Skip to content

Commit 1d37b41

Browse files
authored
Adding scroll worked example (#239)
1 parent b700866 commit 1d37b41

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ $client->users->getUsers([]);
104104
$client->users->scrollUsers();
105105
```
106106

107+
See [here](https://github.com/intercom/intercom-php#scroll) for more info on using the scroll parameter
108+
107109
## Leads
108110

109111
```php
@@ -156,6 +158,8 @@ $client->leads->convertLead([
156158
$client->leads->scrollLeads();
157159
```
158160

161+
See [here](https://github.com/intercom/intercom-php#scroll) for more info on using the scroll parameter
162+
159163
## Visitors
160164
Retrieve `user_id` of a visitor via [the JavaScript API](https://developers.intercom.com/docs/intercom-javascript#section-intercomgetvisitorid)
161165

@@ -406,6 +410,35 @@ You can grab the next page of results using the client:
406410
$client->nextPage($response->pages);
407411
```
408412

413+
## Scroll
414+
The first time you use the scroll API you can just send a simple GET request.
415+
This will return up to 100 records. If you have more than 100 you will need to make another call.
416+
To do this you need to use to scroll_parameter returned in the original response.
417+
Use this for subsequent responses until you get an empty array of records.
418+
This means there are no records and the scroll timer will be reset.
419+
For more information on scroll please see the [API reference](https://developers.intercom.com/reference#iterating-over-all-users)
420+
Here is an example of a simple way to use the scroll for multiple calls:
421+
422+
```
423+
<?php
424+
require "vendor/autoload.php";
425+
use Intercom\IntercomClient;
426+
427+
$intercom= new IntercomClient(getenv('AT'), null);
428+
$resp = $intercom->users->scrollUsers([]);
429+
#var_dump($resp);
430+
$count = 1;
431+
echo "PAGE $count: " . sizeof($resp->users);
432+
echo "\n";
433+
while (!empty($resp->scroll_param && sizeof($resp->users) > 0)){
434+
$count = ++$count;
435+
$resp = $intercom->users->scrollUsers(["scroll_param" => $resp->scroll_param]);
436+
echo "PAGE $count: " . sizeof($resp->users);
437+
echo "\n";
438+
}
439+
?>
440+
```
441+
409442

410443
## Exceptions
411444

0 commit comments

Comments
 (0)