

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Zend/Loader.php'; | |
Zend_Loader::loadClass('Zend_Http_Client'); | |
Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); | |
// ID of Cloud Printer | |
$Printer_ID = ""; | |
// Name of Cloud Printer | |
$Printer_Name = ""; | |
// Description of Cloud Printer | |
$Printer_Description = ""; | |
// Path to Printer Capabilities in PPD Format | |
$Printer_Proxy = ""; | |
// 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/update'); | |
$client->setParameterPost('printer', $Printer_ID); | |
$client->setParameterPost('printer', $Printer_Name); | |
$client->setParameterPost('proxy', $Printer_Proxy); | |
//Pull Capabilities from PPD File | |
$Capabilities = file_get_contents($Printer_PPD); | |
$client->setParameterPost('capabilities', $Capabilities); | |
$client->setParameterPost('defaults', $Capabilities); | |
$client->setParameterPost('status', 'Online'); | |
$client->setParameterPost('description', $Printer_Description); | |
$response = $client->request(Zend_Http_Client::POST); | |
//echo $response; | |
$PrinterResponse = json_decode($response->getBody()); | |
//var_dump($PrinterResponse); | |
$Success = $PrinterResponse->success; | |
//echo "Success: " . $Success . "<br />"; | |
// Printer Information | |
$Printer = $PrinterResponse->printers[0]; | |
$Printer_ID = $Printer->id; | |
//echo "Printer ID: " . $Printer_ID . "<br />"; | |
$Printer_Name = $Printer->name; | |
//echo "Printer Name: " . $Printer_Name . "<br />"; | |
$Printer_Description = $Printer->description; | |
//echo "Printer Description: " . $Printer_Description . "<br />"; | |
$Printer_Status = $Printer->status; | |
//echo "Printer Status: " . $Printer_Status . "<br />"; | |
$Printer_CreateTime = $Printer->createTime; | |
//echo "Printer CreateTime: " . $Printer_CreateTime . "<br />"; | |
?> |
- printerid - Unique printer identification (generated by Google Cloud Print).
- printer - User readable name of the printer being registered (need not be unique).
- proxy - Identification of the printer client or proxy (must be unique).
- capabilities - Printer capabilities (XPS or PPD).
- defaults - Printer default settings (XPS or PPD).
- status - Status string of the printer�e.g., Out of Paper, Online, etc.
- description - Descriptive string about the printer.
- capsHash - A hash or digest value of the capabilities data. This value is useful, for example, to compare values and check whether the local printer's capabilities have changed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"success": true, | |
"message": "Printer updated successfully." | |
} |
Related articles
- Introduction to the Google Cloud Print Services Interface (kinlane.com)
- Google Cloud Print - Client Login (kinlane.com)
- Google Cloud Print - Register (kinlane.com)