Skip to content

Instantly share code, notes, and snippets.

@mimeoconnect
Created February 8, 2011 06:03
Show Gist options
  • Select an option

  • Save mimeoconnect/815961 to your computer and use it in GitHub Desktop.

Select an option

Save mimeoconnect/815961 to your computer and use it in GitHub Desktop.
This fetches a list of cloud print jobs using the Google Cloud Print (GCP) /fetch interface and the Zend PHP Framework.
<?php
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
// ID of the Printer
$Printer_ID = "";
// Gmail User Email
$G_Email = "";
// Gmail User Password
$G_Pass = "";
//Actually Register the Printer
$client = Zend_Gdata_ClientLogin::getHttpClient($G_Email, $G_Pass, 'cloudprint');
// Get Token and Add Headers
$Client_Login_Token = $client->getClientLoginToken();
$client->setHeaders('Authorization','GoogleLogin auth='.$Client_Login_Token);
$client->setHeaders('X-CloudPrint-Proxy','Mimeo');
//GCP Services - Register
$client->setUri('http://www.google.com/cloudprint/interface/fetch');
$client->setParameterPost('printerid', $Printer_ID);
$JobResponse = json_decode($response->getBody());
$Success = $JobResponse->success;
if(isset($JobResponse->jobs))
{
$Jobs = $JobResponse->jobs;
foreach($Jobs as $Job)
{
$Job_ID = $Job->id;
$Job_Title = $Job->title;
$File_URL = $Job->fileUrl;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment