public static function callRest($aConfig, $aData) { try { $sRawDataSign = ''; foreach ($aData as $k => $v) { if ($k != 'checksum' && $k != 'addInfo' && $k != 'description') { $sRawDataSign .= $v; } } $sign = sha1($sRawDataSign . $aConfig['key']); $aData['checksum'] = $sign; $request = new RestRequest($aConfig['url'], 'POST'); $request->buildPostBody($aData); $request->execute(); $http_code = $request->getHTTPCode(); $rs->return = array(); $rs->return['httpcode'] = $http_code; if ($http_code == '200') { $result = json_decode($request->getResponseBody(), true); $rs->return = $result; $rs->return['httpcode'] = $http_code; } else { $rs->return['message'] = $request->getResponseBody(); } return $rs; } catch (Exception $fault) { throw $fault; } }
function setCapabilities($username, $authuser, $authpw) { global $SERVER_URL, $APIVERSION; $url = $SERVER_URL . 'capabilities/' . $APIVERSION . '/' . $username; $request = new RestRequest($url, 'PUT', null, $authuser, $authpw); $request->execute(); echo $request->getResponseBody(); }
public function getRepositoryNames() { $url = $this->baseUrl . "/names"; $method = "GET"; $rest = new RestRequest($url, $method); //$rest->setAcceptType("application/xml"); $rest->execute(); $output = $rest->getResponseBody(); echo $output; }
function getWeather($location) { global $SERVER_URL, $APIKEY; $request = new RestRequest("http://free.worldweatheronline.com/feed/weather.ashx?q=" . $location . "&format=json&num_of_days=2&key=" . $APIKEY, 'GET', ""); //echo "http://free.worldweatheronline.com/feed/weather.ashx?q=".$location."&format=json&num_of_days=2&key=".$APIKEY; $request->execute(); $info = $request->getResponseInfo(); if ($info['http_code'] == 200) { echo $request->getResponseBody(); } else { echo "Error - cannot gather weather info"; } }
function lasthope($username, $authuser, $authpw, $cometurl) { global $SERVER_URL, $APIVERSION; $request = new RestRequest($cometurl, 'POST', "", $authuser, $authpw); $request->execute(); $requestAsArray = json_decode($request->getResponseBody(), true); // create object in php [messageID, text, sender, status, dateTime] $info = $request->getResponseInfo(); if ($info['http_code'] == 200 && (array_key_exists('notificationList', $requestAsArray) || $requestAsArray == null)) { $requestAsArray = $requestAsArray['notificationList']; $returnArray = array(); foreach ($requestAsArray as $key => $value) { $onemessage = array("sessionID" => "", "messageID" => "", "text" => "", "sender" => "", "status" => "", "dateTime" => ""); if (array_key_exists('messageStatusNotification', $value)) { $onemessage["messageID"] = $value['messageStatusNotification']['messageId']; $onemessage["status"] = $value['messageStatusNotification']['status']; $onemessage["sessionID"] = $value['messageStatusNotification']['link'][0]['href']; $onemessage["sessionID"] = explode("/", $onemessage["sessionID"])[8]; } if (array_key_exists('messageNotification', $value)) { $onemessage["messageID"] = $value['messageNotification']['messageId']; $onemessage["text"] = $value['messageNotification']['chatMessage']['text']; $onemessage["sender"] = $value['messageNotification']['senderAddress']; $onemessage["sender"] = str_replace("sip:+", "", $onemessage["sender"]); $onemessage["sender"] = str_replace("tel:+", "", $onemessage["sender"]); $onemessage["sender"] = str_replace("@rcstestconnect.net", "", $onemessage["sender"]); $onemessage["dateTime"] = $value['messageNotification']['dateTime']; $onemessage["sessionID"] = $value['messageNotification']['sessionId']; } if (array_key_exists('chatEventNotification', $value)) { $onemessage["sessionID"] = $value['chatEventNotification']['sessionId']; } $returnArray[] = $onemessage; } $returnArray = json_encode($returnArray); echo $returnArray; } else { echo $info['http_code']; } }
/** * Return objectives from the University of Nottingham Curriculum Mapping system * @param $moduleID * @param $session * @return mixed Array of session and objective data in format required by Rogō */ public function getObjectives($moduleID, $session) { $this->_sess_year = strstr($session, '/', true); $this->_root_url = sprintf($this->_root_url, $this->_sess_year); $this->_module_id = $moduleID; $req = new RestRequest($this->_root_url . "api/find_json?search={$moduleID}&type=module&where=attribute&attrib=code&output=module_session_obs"); $req->execute(); $res = $req->getResponseBody(); $response = $req->getResponseInfo(); if ($response['http_code'] == 0) { $objectives = 'error'; } else { switch ($this->_mapping_level) { case self::LEVEL_MODULE: $objectives = $this->transformCMResponseModule($res, $session); break; default: $objectives = $this->transformCMResponse($res, $session); break; } } return $objectives; }
public function setUomUuid() { $request = new RestRequest($this->config['restUrl'] . 'Uom/list', 'GET'); $request->setUsername($this->config['Username']); $request->setPassword($this->config['Password']); $request->execute(); $responseInfo = $request->getResponseInfo(); $http_code = $responseInfo['http_code']; if ($http_code == '200') { $xml = simplexml_load_string($request->getResponseBody()); $cc = 0; foreach ($xml->uom as $val) { $name = (string) $val->attributes()->name; if ($name == 'шт') { $uomType = $this->modx->getObject('modSystemSetting', 'msklad_uom_type_uuid'); $uomType->set('value', $val->uuid); $uomType->save(); } ++$cc; } unset($xml); } }
* @param (string) $image Image name to search for * @param (string) $path Directory path to search for image * @return (string,boolean) Returns path of image if found, false if not found */ public static function find_image_path($image, $path = "", $depth = 0) { # If no path supplied, get current working directory if ($path == "") {
function deleteAttribute($username, $authuser, $authpw, $attributeName) { global $SERVER_URL, $APIVERSION; $url = $SERVER_URL . 'addressbook/' . $APIVERSION . '/' . $username . '/contacts/' . $contactID . '/attributes/' . $attributeName; //echo $url; $request = new RestRequest($url, 'DELETE', null, $authuser, $authpw); $request->execute(); echo $request->getResponseBody(); }
public function testRestRequestPost() { $url = "http://*****:*****@' . $this->testingFileWithPath); //var_dump( $data ); $rest = new RestRequest($url, $verb, $data); //$rest->setUrl("http://145.247.163.52:8080/BIM_Facility_Management/rest/tests/testPut/ttt"); // http://145.247.163.52:8080/BIM_Facility_Management/rest/uploadIfc $rest->setAcceptType("text/html"); $rest->setLocalFile($this->testingFileWithPath); $rest->execute(); echo $rest->getResponseBody(); echo "\n resp info \n"; var_dump($rest->getResponseInfo()); }
function getGroupParticipants($username, $authuser, $authpw, $sessionID) { global $SERVER_URL, $APIVERSION; $url = $SERVER_URL . 'chat/' . $APIVERSION . '/' . $username . '/group/' . $sessionID . '/participants'; $request = new RestRequest($url, 'GET', null, $authuser, $authpw); $request->execute(); echo $request->getResponseBody(); }
/** * Return objectives from the University of Nottingham Medical School Networked Learning Environment * @param $moduleID * @param $session * @return mixed Array of session and objective data in format required by Rogō */ public function getObjectives($moduleID, $session) { $req = new RestRequest("http://www.nle.nottingham.ac.uk/webServices/RogoRestAPI.php?url=getObjectives/{$moduleID}/{$session}"); $req->execute(); return $req->getResponseBody(); }
<?php require_once ".././include/initialize.php"; $request = new RestRequest('http://api.magazinuldecase.ro'); $request->setPath('/imobile.json'); $request->setVerb('put'); $data = array('key' => '2HVO01c20rHj0lB60jI50dwB', 'tip_oferta' => 'vanzare', 'categorie_imobil' => 'apartament', 'zone_id' => '145', 'orase_id' => '1', 'strada_imobil' => 'Basarabia', 'camere_imobil' => '2', 'bai_imobil' => '1', 'suprafata_imobil' => '56.00', 'pret_imobil' => '60000', 'pret_tva' => 'cu_tva', 'pret_negociabil' => '1', 'afiseaza_pmp' => '1', 'incalzire_imobil' => 'centrala_zona', 'etaj_imobil' => '8', 'etajDin_imobil' => 'P+10', 'an_constructie_imobil' => '1984', 'terase_balcoane' => '1', 'compartimentare' => 'decomandat', 'info_imobil' => 'Confort 1, decomandat, , apometre, boxa la subsol, debara, interfon, lift, curent, apa curenta, canalizare, gaze, telefon; Vecinatati: magazine, RATB, parc, lac, supermarket, spital; cod SP01049', 'Ylat' => '44.43383274527434', 'Ylong' => '26.155072202682515', 'telefon_proprietar' => '44932', 'email' => '*****@*****.**', 'id_intern' => 'SP01049'); $request->buildPostBody($data); $request->execute(); $response = $request->getResponseBody(); print_r($response);
function getNotificationChanList($username, $authuser, $authpw) { global $SERVER_URL, $APIVERSION; $usernameNoPlus = '%2B' . substr($username, 1); $url = $SERVER_URL . 'notificationchannel/' . $APIVERSION . '/' . $usernameNoPlus . '/channels'; echo $url; $request = new RestRequest($url, 'GET', null, $authuser, $authpw); $request->execute(); echo $request->getResponseBody(); }
function loginReadActiveSub($username, $authuser, $authpw) { global $SERVER_URL, $APIVERSION; $usernameNoPlus = '%2B' . substr($username, 1); $url = $SERVER_URL . 'register/' . $APIVERSION . '/' . $usernameNoPlus . '/subscriptions'; echo $url; $request = new RestRequest($url, 'GET', null, $authuser, $authpw); $request->execute(); echo $request->getResponseBody(); }