public function test_user_agent() { global $TEST_SERVER_URL; $api = new RestClient(array('user_agent' => "RestClient Unit Test")); $result = $api->get($TEST_SERVER_URL); $response_json = $result->decode_response(); $this->assertEquals("RestClient Unit Test", $response_json->headers->{"User-Agent"}); }
public function callAjaxReadability() { require 'lib/restclient.php'; $base_url = 'https://www.readability.com/'; $url_to_parse = isset($_POST['posturl']) ? urlencode($_POST['posturl']) : ''; $readability_token = get_option('r2p_setting_token', ''); $endpoint_url = $base_url . "api/content/v1/parser?url={$url_to_parse}&token={$readability_token}"; $api = new RestClient(array('base_url' => $base_url)); $result = $api->get("api/content/v1/parser?url={$url_to_parse}&token={$readability_token}"); if ($result->response == '') { echo '{ "error": "Something went wrong, Please check your \'Readability Parser Token\' settings."}'; } else { echo $result->response; } die; }
function getAllReviewsByUser($userId) { Util::throwExceptionIfNullOrBlank($userId, "userId"); $encodedUserId = Util::encodeParams($userId); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['userId'] = $userId; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/reviews/" . $encodedUserId; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $reviewResponseObj = new ReviewResponseBuilder(); $reviewObj = $reviewResponseObj->buildArrayResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $reviewObj; }
/** * @method * * Get Children of the given folder * * @name getFolderChildren * @label Get Children of the given folder * * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco * @param string | $folderId | FolderId of the Folder whose children is to be listed * @param string | $user | Valid Admin username to connect to Alfresco server * @param string | $pwd | Valid Admin password to connect to Alfresco server * * @return object | $result | Response | * */ function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) { $getChildrenUrl = "{$alfrescoServerUrl}/service/api/node/workspace/SpacesStore/{$folderId}/children"; $alfresco_exec = RestClient::get($getChildrenUrl, $user, $pwd); $sXmlArray = $alfresco_exec->getResponse(); $sXmlArray = trim($sXmlArray); $xXmlArray = simplexml_load_string($sXmlArray); $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1); return $aXmlArray; }
function getUsersByGroup($users) { $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; if (is_array($users)) { $headerParams['userList'] = json_encode($users); } else { $headerParams['userList'] = $users; } $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/groupusers"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $userResponseObj = new UserResponseBuilder(); $userObj = $userResponseObj->buildArrayResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $userObj; }
/** * Retrieves the game by the specified name * * @param gameName * - Name of the game that has to be fetched * * @return Game object containing the game which has been created */ function getGameByName($gameName) { Util::throwExceptionIfNullOrBlank($gameName, "Game Name"); $encodedGameName = Util::encodeParams($gameName); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['name'] = $gameName; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/" . $encodedGameName; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $gameResponseObj = new GameResponseBuilder(); $gameObj = $gameResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $gameObj; }
/** * Perform REST GET request to API * @param string $path Absolute resource path * @return array */ protected function _get($path, $params = array()) { $uri = self::getBaseUri() . $path; $client = RestClient::get($uri, $params, $this->_user, $this->_password, self::$baseHeaders); if ($client->getResponseCode() !== 200) { throw new Exception(trim($client->getResponseMessage()) . ": " . trim($client->getResponse())); } if ($client->getResponseContentType() != 'application/json') { throw new Exception("Unexpected response type: " . $client->getResponseContentType()); } $result = json_decode($client->getResponse()); if ($result->success === false) { throw new Exception("Nets fees request failed: {$result->message}"); } return $result->data; }
$matricula = $_POST['matricula']; if (validaFormCalculaVCT()) { function capturarDadosVCT($matricula) { $dao = new dao_class(); // $rowEntrevistado = $dao->selectEntrevistado($matricula); $rowDadosAntropometricos = $dao->selectDadosAntropometricos($matricula); $vetor = array('peso' => $rowDadosAntropometricos['nr_peso'], 'alturaCm' => $rowDadosAntropometricos['nr_altura'], 'sexo' => $rowDadosAntropometricos['tp_sexo'], 'idade' => getIdade($rowDadosAntropometricos['dt_nascimento']) / 12, 'nivel_esporte' => $rowDadosAntropometricos['nr_nivel_esporte']); return $vetor; } $dados = capturarDadosVCT($matricula); if ($dados && $dados['idade'] != 0) { $restClient = new RestClient(array('base_url' => "http://localhost/NutrIF_service")); $header = array('user_agent' => "nutrif-php/1.0", 'content-type' => "application/json"); // Método get. $result = $restClient->get('analisarVCT', $vetor, $header); $vct = $result->info->http_code; $_SESSION['vct'] = $vct; header("location: formCalculaVCT.php"); } else { $msg = "Matrícula não encontrada"; $_SESSION['erro'] = $msg; header("location: formCalculaVCT.php"); } } else { header("location: formCalculaVCT.php"); } /* } else { header("location: formCalculaVCT.php"); }*/ function validaFormCalculaVCT()
$url = "http://173.254.41.118:8080/mycorpus/sentiment"; $response = \Httpful\Request::post($url)->sendsJson()->body($lsa_post)->send(); // And you're ready to go! $code = $response->code; //http://173.254.41.118:8080/mycorpus /sentiment if ($code == 200) { $url = "http://173.254.41.118:8080/mycorpus/sentiment/" . $id; $response = \Httpful\Request::get($url)->send(); $sentiment = $response->body->sentiment; $code = $response->code; //http://173.254.41.118:8080/mycorpus /sentiment/ + myPost["_id"] //print_r($sentiment); if ($code == 200) { $url = "http://173.254.41.118:8080/mycorpus/lsa/" . $id; $restclient = new RestClient(); $result = $restclient->get($url); $lsa = json_decode($result->response, true); //print_r($lsa); $lsa_post = $lsa['post_assignments']; $lsa_topic = $lsa['topic_assignments']; //print_r($lsa_topic); foreach ($lsa_topic['0'] as $value) { $str = strlen($value); if ($str >= 4) { $topic_01[] = $value; } } foreach ($lsa_topic['1'] as $value) { $str = strlen($value); if ($str >= 4) { $topic_02[] = $value;
<?php require 'restclient.php'; $api = new RestClient(); $coupons = $api->get('http://allcoupon.jp/api-v2/coupon', array('limit' => '10', 'output' => 'json', 'apikey' => '9EBgSyRbAPmutrWE')); echo "<pre>"; print_r(json_decode($coupons->response));
/** * Pull message based on the correlation id * @param queueName The name of the queue from which the message has to be pulled * @param receiveTimeOut Receive time out * @param correlationId Correlation Id for which message has to be pulled * @return Queue containing message which has pulled based on the correlation id */ function receiveMessageByCorrelationId($queueName, $receiveTimeOut, $correlationId) { Util::throwExceptionIfNullOrBlank($queueName, "Queue Name"); Util::throwExceptionIfNullOrBlank($receiveTimeOut, "Receive Time Out"); Util::throwExceptionIfNullOrBlank($correlationId, "Correlation Id"); $encodedQueueName = Util::encodeParams($queueName); $encodedReceiveTimeOut = Util::encodeParams($receiveTimeOut); $encodedCorrelationId = Util::encodeParams($correlationId); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['queueName'] = $queueName; $signParams['receiveTimeOut'] = $receiveTimeOut; $signParams['correlationId'] = $correlationId; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $this->messageUrl . "/" . $encodedQueueName . "/" . $encodedReceiveTimeOut . "/" . $encodedCorrelationId; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $queueResponseObj = new QueueResponseBuilder(); $queueObj = $queueResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $queueObj; }
/** * Fetches all the Photos based on the userName and tag * * @params userName * - Name of the User whose photos have to be fetched * @params tag * - tag on which basis photos have to be fetched * * @return List of Album object containing all the Photos for the given * userName */ public function getTaggedPhotos($userName, $tag) { Util::throwExceptionIfNullOrBlank($userName, "User Name"); Util::throwExceptionIfNullOrBlank($tag, "Tag Name"); $encodedUserName = Util::encodeParams($userName); $encodedTag = Util::encodeParams($tag); $objUtil = new Util($this->apiKey, $this->secretKey); $albumList = array(); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['userName'] = $userName; $signParams['tag'] = $tag; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/tag/" . $encodedTag . "/userName/" . $encodedUserName; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $photoResponseObj = new AlbumResponseBuilder(); $albumList = $photoResponseObj->buildArrayResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $albumList; }
<?php include dirname(__FILE__) . '/config.php'; $client = new RestClient('http://gdata.youtube.com/feeds/api', array('#header' => array('X-GData-Key' => sprintf('key=%s', YOUTUBE_API_KEY)))); $keyword = 'slash'; $response = $client->get('/videos', array('#query' => array('q' => $keyword, 'orderby' => 'viewCount', 'alt' => 'json')), TRUE); $html = array(); $html[] = '<ul>'; foreach ($response->decoded->feed->entry as $entry) { $html[] = sprintf('<li>%s</li>', $entry->title->{'$t'}); } $html[] = '</ul>'; echo implode("\n", $html); printf('<pre>%s</pre>', print_r($response, TRUE));
<?php include "restclient.php"; if ($_POST) { $azione = $_POST["azione"]; if ($azione == "Read temperature") { $api = new RestClient(); $result = $api->get("http://192.168.0.3/rt.html"); } header('Location: /test_arduino_temp_wifi/test.php'); }
function getGiftCount($name, $userName) { $responseObj = new App42Response(); Util::throwExceptionIfNullOrBlank($name, "Name"); Util::throwExceptionIfNullOrBlank($userName, "User Name"); $encodedName = Util::encodeParams($name); $encodedUserName = Util::encodeParams($userName); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['name'] = $name; $signParams['userName'] = $userName; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/giftrequest/" . $encodedName . "/" . $encodedUserName; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $responseObj->setStrResponse($response->getResponse()); $responseObj->setResponseSuccess(true); $giftResponseObj = new GiftResponseBuilder(); $responseObj->setTotalRecords($giftResponseObj->getTotalRecords($response->getResponse())); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
<?php require 'oauth_common/lib/OAuth.php'; require 'oauth_common/includes/OAuthSignatureMethod_HMAC.inc'; require 'rest_client/includes/RestClient.php'; require 'rest_client/includes/RestClientRequest.php'; require 'rest_client/includes/RestClientOAuth.php'; $consumer = new OAuthConsumer('', ''); $token = new OAuthToken('', ''); $oauth = new RestClientOAuth($consumer, $token, new OAuthSignatureMethod_HMAC('sha1'), TRUE); $client = new RestClient($oauth, new RestClientBaseFormatter(RestClientBaseFormatter::FORMAT_JSON)); $time = microtime(TRUE); var_dump($client->get('http://localhost:8000/some/res', array())); $time = (microtime(TRUE) - $time) * 1000; print "Ay, that took {$time} milliseconds";
function testUnpreciseBench() { $c = RestClient::get($this->url . "/Foo/bench"); echo $c->getResponse(); }
<?php echo 'Arduino REST client<br>'; include "restclient.php"; $api = new RestClient(); $result = $api->get("http://192.168.0.3/stato.html"); $code = $result->info->http_code; if ($code == 200) { $xml = new SimpleXMLElement($result->response); echo "Loaded XML..."; } else { echo "GET failed, error code: " . $code; } ?> <html> <title> Remote control ARDUINO </title> <body> <center> <form action="test_controller.php" method="POST"> <table border="0" width="25%"> <tr> <th align="left"> Status Arduino </th> <th> <?php $code == 200 ? print "<font color=green> ONLINE </font>" : (print "<font color=red> OFFLINE </font>"); ?> </th> </tr>
function getFacebookProfilesFromIds($facebookIds) { Util::throwExceptionIfNullOrBlank($facebookIds, "FacebookIds"); $objUtil = new Util($this->apiKey, $this->secretKey); $body = null; try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); if (is_array($facebookIds)) { $headerParams['userList'] = json_encode($facebookIds); } else { $headerParams['userList'] = $facebookIds; } $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/facebook/ids"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $socialResponseObj = new SocialResponseBuilder(); $socialObj = $socialResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $socialObj; }
function getActivityCountByUser($userId) { Util::throwExceptionIfNullOrBlank($userId, "UserId"); $encodedUserId = Util::encodeParams($userId); $objUtil = new Util($this->apiKey, $this->secretKey); $bravoObj = new App42Response(); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['userId'] = $userId; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/activity/userId/" . $encodedUserId . "/count"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $bravoObj->setStrResponse($response->getResponse()); $bravoObj->setResponseSuccess(true); $bravoResponseObj = new BravoBoardResponseBuilder(); $bravoObj->setTotalRecords($bravoResponseObj->getTotalRecords($response->getResponse())); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $bravoObj; }
function getCurrentTime() { $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/currentTime"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $timerResponseObj = new TimerResponseBuilder(); $timerObj = $timerResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $timerObj; }
function getCountByQuery($dbName, $collectionName, $query) { Util::throwExceptionIfNullOrBlank($dbName, "DataBase Name"); Util::throwExceptionIfNullOrBlank($collectionName, "Collection Name"); Util::throwExceptionIfNullOrBlank($query, "query"); $encodedDbName = Util::encodeParams($dbName); $encodedCollectionName = Util::encodeParams($collectionName); $responseObj = new App42Response(); $objUtil = new Util($this->apiKey, $this->secretKey); $queryObject = null; if ($query instanceof JSONObject) { $queryObject = array(); array_push($queryObject, $query); } else { $queryObject = $query; } try { $params = null; $storageObj = new App42Response(); $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['dbName'] = $dbName; $signParams['collectionName'] = $collectionName; $signParams['jsonQuery'] = json_encode($queryObject); $queryParams['jsonQuery'] = json_encode($queryObject); $params = array_merge($queryParams, $signParams); $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/findDocsByQuery" . "/dbName/" . $encodedDbName . "/collectionName/" . $encodedCollectionName; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $storageResponseObj = new StorageResponseBuilder(); $storageObj = $storageResponseObj->buildResponse($response->getResponse()); $totalRecord = $storageObj->getRecordCount(); $body = '{"app42":{"response":{"totalRecords":"' . $totalRecord . '"}}}'; $responseObj->setStrResponse($body); $responseObj->setResponseSuccess(true); $responseObj->setTotalRecords($totalRecord); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $responseObj; }
/** * Recommendations based on SlopeOne Algorithm for all Users * * @param howMany * - Specifies that how many recommendations have to be found * * @returns Recommender Object for all Users */ function slopeOneForAll($howMany) { Util::throwExceptionIfNullOrBlank($howMany, "How Many"); Util::throwExceptionIfHowManyNotValid($howMany, "How Many"); $encodedHowMany = Util::encodeParams($howMany); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['howMany'] = $howMany; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/slopeOne/all/" . $encodedHowMany; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $recommendResponseObj = new RecommenderResponseBuilder(); $recommendObj = $recommendResponseObj->buildResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $recommendObj; }
<h4>Label</h4> <span class="text-muted">Something else</span> </div> <div class="col-xs-6 col-sm-3 placeholder"> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" width="200" height="200" class="img-responsive" alt="Generic placeholder thumbnail"> <h4>Label</h4> <span class="text-muted">Something else</span> </div> </div> --> <?php //DEBUG // ini_set('display_errors', 'On'); $api = new RestClient(array('base_url' => "http://146.193.41.50:8080/trace")); $result = $api->get("tracker/sessions/" . $_SESSION["username"])->decode_response(); echo "<h2 class=\"sub-header\" id=\"userSessionsHeader\">User Sessions: " . count($result) . "</h2>"; ?> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>Sessions IDs</th> <th>Time and Date</th> <!-- <th>Date</th>--> <!-- <th>Route</th>--> </tr> </thead> <tbody id="traceSessions">
/** * Fetch the name of all storage stored on the cloud. * * @return Geo object containing List of all the storage created * */ function getAllStorage($max = null, $offset = null) { $argv = func_get_args(); if (count($argv) == 0) { $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/storage"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $geoResponseObj = new GeoResponseBuilder(); $geoObj = $geoResponseObj->buildArrayResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $geoObj; } else { /** * Fetch the name of all storage stored on the cloud by Paging. * @params max * - Maximum number of records to be fetched * @params offset * - From where the records are to be fetched * * @return Geo object containing List of all the storage created */ Util::throwExceptionIfNullOrBlank($max, "Max"); Util::throwExceptionIfNullOrBlank($offset, "Offset"); Util::validateMax($max); $encodedMax = Util::encodeParams($max); $encodedOffset = Util::encodeParams($offset); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['max'] = $max; $signParams['offset'] = $offset; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/paging" . "/" . $encodedMax . "/" . $encodedOffset; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $geoResponseObj = new GeoResponseBuilder(); $geoObj = $geoResponseObj->buildArrayResponse($response->getResponse()); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $geoObj; } }
/** * Fetch count of log messages based on Date range * * @param startDate * - Start date from which the count of log messages have to be * fetched * @param endDate * - End date upto which the count of log messages have to be * fetched * * @return App42Response object containing count of fetched messages */ function fetchLogCountByDateRange($startDate, $endDate) { Util::throwExceptionIfNullOrBlank($startDate, "Start Date"); Util::throwExceptionIfNullOrBlank($endDate, "End Date"); $validateStartDate = Util::validateDate($startDate); $validateEndDate = Util::validateDate($endDate); $encodedStartDate = Util::encodeParams($startDate); $encodedEndDate = Util::encodeParams($endDate); $objUtil = new Util($this->apiKey, $this->secretKey); try { $params = null; $strStartDate = date("Y-m-d\\TG:i:s", strtotime($startDate)) . substr((string) microtime(), 1, 4) . "Z"; $strEndDate = date("Y-m-d\\TG:i:s", strtotime($endDate)) . substr((string) microtime(), 1, 4) . "Z"; $logObj = new App42Response(); $headerParams = array(); $queryParams = array(); $signParams = $this->populateSignParams(); $metaHeaders = $this->populateMetaHeaderParams(); $headerParams = array_merge($signParams, $metaHeaders); $signParams['startDate'] = $strStartDate; $signParams['endDate'] = $strEndDate; $signature = urlencode($objUtil->sign($signParams)); //die(); $headerParams['signature'] = $signature; $contentType = $this->content_type; $accept = $this->accept; $baseURL = $this->url; $baseURL = $baseURL . "/startDate/" . $strStartDate . "/endDate/" . $strEndDate . "/count"; $response = RestClient::get($baseURL, $params, null, null, $contentType, $accept, $headerParams); $logObj->setStrResponse($response->getResponse()); $logObj->setResponseSuccess(true); $logResponseObj = new LogResponseBuilder(); $logObj->setTotalRecords($logResponseObj->getTotalRecords($response->getResponse())); } catch (App42Exception $e) { throw $e; } catch (Exception $e) { throw new App42Exception($e); } return $logObj; }