<?php // fix this include if you aren't running from the examples dir require_once '/home/jeichorn/sandbox/Bluga/trunk/Bluga/PEAR2/Autoload.php'; // put config.php in the same dir as the notify script or if (file_exists(dirname(__FILE__) . '/config.php')) { include dirname(__FILE__) . '/config.php'; } // check for a config file in your home dir // you can set the items above in .webthumb.php in your home dir $home = getenv('HOME'); if (file_exists("{$home}/.webthumb.php")) { include "{$home}/.webthumb.php"; } // setup db connection $pdo = new PDO($DB_DSN, $DB_USER, $DB_PASSWORD); $stmtJob = $pdo->prepare('update jobs set end_time = ? where job_id = ?'); $id = $_GET['id']; $urlId = $_GET['url_id']; $url = 'http://webthumb.bluga.net/data/' . substr($id, -2) . '/' . substr($id, -4, -2) . '/' . substr($id, -6, -4) . "/{$id}-thumb_{$THUMB_SIZE}.jpg"; $request = new PEAR2_HTTP_Request($url); $request->requestToFile($OUTPUT_DIR . '/' . $urlId . '.jpg'); $stmtJob->execute(array(date('Y-m-d H:i:s'), $id)); echo "Were good thanks";
/** * handles the actual transmission of the payload. * * @param unknown_type $request * @return String the response from the server. */ protected function _transmitRequest($request) { $http = new PEAR2_HTTP_Request($this->webthumbApiEndpoint, $this->httpRequestAdapter); $http->verb = "POST"; $http->body = $request; if ($this->debug) { echo "Using Adapter " . $http->getAdapterName() . "\n"; echo "Making request to :" . $this->webthumbApiEndpoint . "\n"; echo "Request Body is\n"; echo "#################\n"; echo $http->body; echo "#################\n\n"; } $response = $http->sendRequest(); if ($response->code != 200) { if ($this->debug) { echo "We had an error the response object is\n"; echo "#################\n"; echo var_dump($response); echo "#################\n"; } throw new Exception('None 200 http response code from the API Endpoint (' . $response->code . ')', $response); } return $response; }