Example #1
0
 public function testSettersGetters()
 {
     $client = new Postman_Google_Client();
     $client->setClientId("client1");
     $client->setClientSecret('client1secret');
     $client->setState('1');
     $client->setApprovalPrompt('force');
     $client->setAccessType('offline');
     $client->setRedirectUri('localhost');
     $client->setApplicationName('me');
     $this->assertEquals('object', gettype($client->getAuth()));
     $this->assertEquals('object', gettype($client->getCache()));
     $this->assertEquals('object', gettype($client->getIo()));
     $client->setAuth(new Postman_Google_Auth_Simple($client));
     $client->setAuth(new Postman_Google_Auth_OAuth2($client));
     try {
         $client->setAccessToken(null);
         die('Should have thrown an Postman_Google_Auth_Exception.');
     } catch (Postman_Google_Auth_Exception $e) {
         $this->assertEquals('Could not json decode the token', $e->getMessage());
     }
     $token = json_encode(array('access_token' => 'token'));
     $client->setAccessToken($token);
     $this->assertEquals($token, $client->getAccessToken());
 }
Example #2
0
include_once "templates/base.php";
echo pageHeader("Batching Queries");
/************************************************
  We're going to use the simple access to the
  books API again as an example, but this time we
  will batch up two queries into a single call.
 ************************************************/
require_once realpath(dirname(__FILE__) . '/../autoload.php');
/************************************************
  We create the client and set the simple API
  access key. If you comment out the call to
  setDeveloperKey, the request may still succeed
  using the anonymous quota.
 ************************************************/
$client = new Postman_Google_Client();
$client->setApplicationName("Client_Library_Examples");
$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.
       ************************************************/