Beispiel #1
0
 public function testClient()
 {
     $client = new Postman_Google_Client();
     $client->setAccessType('foo');
     $client->setDeveloperKey('foo');
     $req = new Postman_Google_Http_Request('http://foo.com');
     $client->getAuth()->sign($req);
     $params = $req->getQueryParams();
     $this->assertEquals('foo', $params['key']);
     $client->setAccessToken(json_encode(array('access_token' => '1')));
     $this->assertEquals("{\"access_token\":\"1\"}", $client->getAccessToken());
 }
Beispiel #2
0
 public function getClient()
 {
     $client = new Postman_Google_Client();
     $client->setDeveloperKey(self::KEY);
     if (strlen($this->token)) {
         $client->setAccessToken($this->token);
     }
     if (strlen($this->memcacheHost)) {
         $client->setClassConfig('Postman_Google_Cache_Memcache', 'host', $this->memcacheHost);
         $client->setClassConfig('Postman_Google_Cache_Memcache', 'port', $this->memcachePort);
     }
     return $client;
 }
Beispiel #3
0
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.
       ************************************************/
    $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);