0
私はXeroOAuth-PHP SDKを使用しており、プライベートアプリケーション用の請求書をダウンロードしようとしています - これまでの100個の請求書の最初のバッチを認証してダウンロードするのが得意です。XeroOAuth-PHP - ページネーションの例
私は今、一度に100枚の請求書のグループをダウンロードするには、ページ区切りが含まれるようにコードを拡張するために探しています - 私が使用して要求ごとに請求書の数を取得することができます:
$totalInvoices = count($invoices->Invoices[0]);
ではなく、必ずどのようにページ1から開始するループを追加し、請求書の数が100未満になるまで続行しますか?
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoices', 'core'), array('where' => 'Type=="ACCREC"'));
私はこれらの線に沿って何かを探しています:ここで
は、最初の100枚の売掛金の請求書を取得するリクエストです// set pagiation to page 1
$page = 1;
// start a loop for the $page counter
// download first page of invoices (first 100) - not sure how to specify page 1 here
$response = $XeroOAuth->request('GET', $XeroOAuth->url('Invoices', 'core'), array('where' => 'Type=="ACCREC"', 'page' => $page));
if ($XeroOAuth->response['code'] == 200) {
// Get total found invoices
$totalInvoices = count($invoices->Invoices[0]);
// Parse Invoices
$invoices = $XeroOAuth->parseResponse($XeroOAuth->response['response'], $XeroOAuth->response['format']);
// Loop through each invoice
$recnum = 1;
foreach($invoices as $invoice){
// Do Stuff
pr($invoices->Invoices[$recnum]->Invoice);
$recnum++;
}
} else {
outputError($XeroOAuth);
}
// Exit once $totalInvoices < 100
$page++;