Created
February 7, 2011 05:03
-
-
Save mimeoconnect/814019 to your computer and use it in GitHub Desktop.
This deletes an existing cloud printer using the Google Cloud Print (GCP) /delete interface and the Zend PHP Framework
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 = ""; | |
$PostCheckQuery = "SELECT G_Pass,Client_Login_Token FROM print_user WHERE G_Email = '" . $G_Email . "'"; | |
$CheckResult = mysql_query($PostCheckQuery) or die('Query failed: ' . mysql_error()); | |
if($CheckResult && mysql_num_rows($CheckResult)) | |
{ | |
$CheckResult = mysql_fetch_assoc($CheckResult); | |
$Client_Login_Token = $CheckResult['Client_Login_Token']; | |
$G_Pass = $CheckResult['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/delete'); | |
$client->setParameterPost('printerid', $Printer_ID); | |
$response = $client->request(Zend_Http_Client::POST); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment