Beispiel #1
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
require_once 'GoogleCloudPrint.php';
session_start();
// Create object
$gcp = new GoogleCloudPrint();
$gcp->setAuthToken($_SESSION['accessToken']);
$printers = $gcp->getPrinters();
//print_r($printers);
$printerid = "";
if (count($printers) == 0) {
    echo "Could not get printers";
    exit;
} else {
    $printerid = $printers[0]['id'];
    // Pass id of any printer to be used for print
    // Send document to the printer
    $resarray = $gcp->sendPrintToPrinter($printerid, "Printing Doc using Google Cloud Printing", "./pdf.pdf", "application/pdf");
    if ($resarray['status'] == true) {
        echo "Document has been sent to printer and should print shortly.";
    } else {
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
require_once 'GoogleCloudPrint.php';
// Create object
$gcp = new GoogleCloudPrint();
// Login to Googel, email address and password is required
if ($gcp->loginToGoogle("*****@*****.**", "someonepassword")) {
    // Login is successfull so now fetch printers
    $printers = $gcp->getPrinters();
    echo "<pre>";
    print_r($printers);
    echo "</pre>";
    $printerid = "";
    if (count($printers) == 0) {
        echo "Could not get printers";
        exit;
    } else {
        $printerid = $printers[0]['id'];
        // Pass id of any printer to be used for print
    }
Beispiel #3
0
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
require_once 'Config.php';
require_once 'GoogleCloudPrint.php';
// Create object
$gcp = new GoogleCloudPrint();
// Replace token you got in offlineToken.php
$refreshTokenConfig['refresh_token'] = 'YOUR-OFFLINE-ACCESS-TOKEN';
$token = $gcp->getAccessTokenByRefreshToken($urlconfig['refreshtoken_url'], http_build_query($refreshTokenConfig));
$gcp->setAuthToken($token);
$printers = $gcp->getPrinters();
//print_r($printers);
$printerid = "";
if (count($printers) == 0) {
    echo "Could not get printers";
    exit;
} else {
    $printerid = $printers[0]['id'];
    // Pass id of any printer to be used for print
    // Send document to the printer
    $resarray = $gcp->sendPrintToPrinter($printerid, "Printing Doc using Google Cloud Printing", "./pdf.pdf", "application/pdf");
Beispiel #4
0
*/
require_once 'Config.php';
require_once 'GoogleCloudPrint.php';
if (isset($_GET['op'])) {
    if ($_GET['op'] == "getauth") {
        header("Location: " . $urlconfig['authorization_url'] . "?" . http_build_query($redirectConfig));
        exit;
    } else {
        if ($_GET['op'] == "offline") {
            header("Location: " . $urlconfig['authorization_url'] . "?" . http_build_query(array_merge($redirectConfig, $offlineAccessConfig)));
            exit;
        }
    }
}
session_start();
// Google redirected back with code in query string.
if (isset($_GET['code']) && !empty($_GET['code'])) {
    $code = $_GET['code'];
    $authConfig['code'] = $code;
    // Create object
    $gcp = new GoogleCloudPrint();
    $responseObj = $gcp->getAccessToken($urlconfig['accesstoken_url'], $authConfig);
    $accessToken = $responseObj->access_token;
    // We requested offline access
    if (isset($responseObj->refresh_token)) {
        header("Location: offlineToken.php?offlinetoken=" . $responseObj->refresh_token);
        exit;
    }
    $_SESSION['accessToken'] = $accessToken;
    header("Location: example.php");
}