private function _requestRaw($meth, $url, $params = array(), $body = '') { $apiPublicKey = $this->_apiPublicKey; $apiPrivateKey = $this->_apiPrivateKey; //If authenticate is enabled. Then help out the developer by letting them know if they forgot to set api keys if ($this->_authenticate) { if (!$apiPublicKey) { $apiPublicKey = TrustedSearch::$apiPublicKey; } if (!$apiPublicKey) { throw new TrustedSearch_AuthenticationError('No API Public key provided. (HINT: set your API key using "TrustedSearch::setApiPublicKey(<API-KEY>)". You can generate API keys from the TrustedSearch web interface. See https://trustedsearch.org/api for details, or email support@trustedsearch.org if you have any questions.'); } if (!$apiPrivateKey) { $apiPrivateKey = TrustedSearch::$apiPrivateKey; } if (!$apiPrivateKey) { throw new TrustedSearch_AuthenticationError('No API Private key provided. (HINT: set your API key using "TrustedSearch::setApiPrivateKey(<API-KEY>)". You can generate API keys from the TrustedSearch web interface. See https://trustedsearch.org/api for details, or email support@trustedsearch.org if you have any questions.'); } } if (!TrustedSearch::getApiVersion()) { throw new TrustedSearch_AuthenticationError('No API Version specified. (HINT: set your API key using "TrustedSearch::setApiVersion(<API-KEY>)". You can generate API keys from the TrustedSearch web interface. See https://trustedsearch.org/api for details, or email support@trustedsearch.org if you have any questions.'); } $absUrl = $this->apiUrl($url); $params = self::_encodeObjects($params); $langVersion = phpversion(); $uname = php_uname(); $ua = array('bindings_version' => TrustedSearch::VERSION, 'lang' => 'php', 'lang_version' => $langVersion, 'publisher' => 'trustedsearch', 'uname' => $uname); $headers = array('X-TrustedSearch-Client-User-Agent: ' . json_encode($ua), 'User-Agent: TrustedSearch/v1 PhpBindings/' . TrustedSearch::VERSION, 'Content-Type: application/json'); if (TrustedSearch::$apiVersion) { $headers[] = 'TrustedSearch-Version: ' . TrustedSearch::$apiVersion; } if ($this->_authenticate) { //Handle Authentication/Signature switch (TrustedSearch::getApiVersion()) { case '1': case '2': $timestamp = time(); $request = array('resource' => $url, 'content' => $body, 'timestamp' => $timestamp, 'privateKey' => TrustedSearch::$apiPrivateKey); $signature = $this->_generateV1Signature($request); $params = array_merge($params, array('signature' => $signature, 'apikey' => TrustedSearch::$apiPublicKey, 'timestamp' => $timestamp)); # code... break; default: # code... break; } } list($rbody, $rcode, $rhead) = $this->_curlRequest($meth, $absUrl, $headers, $params, $body); return array($rbody, $rcode, $rhead); }
public function getPagination() { $data = $this->getResponse(); if (TrustedSearch::getApiVersion() == 2) { return $data['body']['pagination']; } }