Beispiel #1
0
$apiKey = "<YOUR_API_KEY>";
// Change to your API key.
// Warn if the API key isn't changed!
if ($apiKey == '<YOUR_API_KEY>') {
    echo missingApiKeyWarning();
} else {
    $client->setDeveloperKey($apiKey);
    $service = new Postman_Google_Service_Books($client);
    /************************************************
        To actually make the batch call we need to 
        enable batching on the client - this will apply 
        globally until we set it to false. This causes
        call to the service methods to return the query
        rather than immediately executing.
       ************************************************/
    $client->setUseBatch(true);
    /************************************************
       We then create a batch, and add each query we 
       want to execute with keys of our choice - these
       keys will be reflected in the returned array.
      ************************************************/
    $batch = new Postman_Google_Http_Batch($client);
    $optParams = array('filter' => 'free-ebooks');
    $req1 = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
    $batch->add($req1, "thoreau");
    $req2 = $service->volumes->listVolumes('George Bernard Shaw', $optParams);
    $batch->add($req2, "shaw");
    /************************************************
        Executing the batch will send all requests off
        at once.
       ************************************************/