Skip to content

Instantly share code, notes, and snippets.

@jaredk2g
Created June 21, 2019 15:46
Show Gist options
  • Save jaredk2g/82a12ffb2dcc3731c62fd8d1e6e0973b to your computer and use it in GitHub Desktop.
Save jaredk2g/82a12ffb2dcc3731c62fd8d1e6e0973b to your computer and use it in GitHub Desktop.
Retrieves customer list through Invoiced using pagination
<?php
require("../vendor/autoload.php");
$invoiced = new Invoiced\Client("MY-API-KEY");
$page = 1;
$hasNextPage = true;
while ($hasNextPage) {
list($customers, $metadata) = $invoiced->Customer->all(['page' => $page]);
foreach ($customers as $customer) {
echo "$customer->name\n";
}
$hasNextPage = isset($metadata->links['next']);
$page++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment