/** * Constructor * * Sets up the client */ public function __construct() { $this->restClient = Services::get('restclient'); $this->restClient->addHeader('Accept', 'application/json'); $this->restClient->setFormat('json'); $this->loadConfig(); $this->restClient->setUrl($this->getURL()); $this->restClient->addParam('key', $this->getConfig('key')); }
/** * Reset the class state to its default */ public function reset() { $this->restClient->reset(); $this->restClient->setUrl($this->getURL()); $this->restClient->addParam('key', $this->getConfig('key')); $this->params = array(); $this->result = array(); $this->vistaMethod = ''; $this->requestMethod = 'get'; }
/** * Creates the RESTClient * @param string $url=null [optional] * @return RestClient */ public static function createClient($url=null) { $client = new RestClient; if($url != null) { $client->setUrl($url); } return $client; }
<?php include '../includes/settings.inc.php'; include '../fcts/restclient.class.php'; $rest = new RestClient(); if (isset($_GET['action']) && $_GET['action'] == "logout") { $_SESSION = array(); if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]); } session_destroy(); } if (isset($_GET['code'])) { $_SESSION['meetupToken'] = $_GET['code']; $authorisationData = array("client_id" => $_CONFIG['meetupKey'], "client_secret" => $_CONFIG['meetupSecret'], "grant_type" => "authorization_code", "redirect_uri" => $_CONFIG['meetupWebsite'], "code" => $_SESSION['meetupToken']); //Reset application authorisation $reply = $rest->setUrl('https://secure.meetup.com/oauth2/access')->post($authorisationData); $_SESSION['access_token'] = $reply['access_token']; //Read profile $profil = $rest->setUrl('https://api.meetup.com/2/member/self/?access_token=' . $_SESSION['access_token'])->get(); $_SESSION['name'] = $profil['name']; $_SESSION['thumb_link'] = $profil['photo']['thumb_link']; $_SESSION['id'] = $profil['id']; }
<?php include '../includes/config.inc.php'; include '../includes/settings.inc.php'; include '../fcts/hiking.fct.php'; include '../fcts/restclient.class.php'; include '../fcts/event.fct.php'; //If the user is logged and the event id is set if (isAuthenticated() && $_SESSION['id'] == $GLOBALS['organiserId'] && isset($_GET['id'])) { $event = readEventId($bdd, $_GET['id']); $venueId = $event['venueId']; $accessData = array("access_token" => $_SESSION['access_token']); $rest = new RestClient(); if ($event['venueId'] == 0) { $venueData = array("name" => $event['venueName'], "address_1" => $event['venueAddress'], "city" => $event['venueCity'], "country" => $event['venueCountry']); $data = $rest->setUrl('https://api.meetup.com/' . $GLOBALS['group_urlname'] . '/venues')->post($venueData, $accessData); $venueId = $data['id']; } $eventData = array("name" => $event['name'], "group_id" => $GLOBALS['group_id'], "group_urlname" => $GLOBALS['group_urlname'], "description" => $event['description'], "event_hosts" => $event['event_organiser'], "rsvp_limit" => $event['rsvp_limit'], "how_to_find_us" => $event['how_to_find_us'], "time" => strtotime($event['time']) * 1000, "venue_id" => $venueId); $data = $rest->setUrl('https://api.meetup.com/2/event')->post($eventData, $accessData); } else { header("HTTP/1.1 403 Access denied"); echo 'Access denied'; }
/** * submit the http request to the node server to generate the thumbnail * @param $assetHref * @return boolean */ public function requestThumbnail($assetHref) { $url = Configure::read('Chaucer.thumbnailHost'); if (strlen($url) > 0) { $pageKey = Configure::read('Chaucer.rootFolder') . $this->bookId . '/' . $this->epub->epubRoot() . dirname($this->epub->EpubSpine->getContentOpfLocation()) . '/' . $assetHref; $rest = new RestClient(); $bookItem = $this->bookData->getBookItem(); $width = (int) $bookItem['ChChaucerBookVersion']['book_width']; $height = (int) $bookItem['ChChaucerBookVersion']['book_height']; if (!$width) { $width = 768; $height = 1024; } CakeLog::debug('[ImportProcessor::requestThumbnail] Requesting thumbnail from ' . $url . ' for path ' . $pageKey . ' height: ' . $height . ' width:' . $width); $response = $rest->setUrl($url)->setData(array('path' => $pageKey, 'height' => $height, 'width' => $width, 'bucket' => Configure::read('Chaucer.s3Bucket')))->get(); return $rest->isGoodResponse(); } return false; }