/** * This is a universal method all client types must implement to * take a Cosmos_Api_Request object and make the call via the * underlying client object. * * @param Cosmos_Api_Request $request * @return Cosmos_Api_Response */ public function cosmosRequest(Cosmos_Api_Request $request) { $apiKey = Cosmos_Api::getApiKey($request->getOauthParam('oauth_consumer_key')); if (!$apiKey) { Zend_Debug::dump($apiKey); // throw new Cosmos_Api_Exception('Unauthorized - Bad consumer key provided', 401); } $this->_server->setRequest($request); $response = $this->_server->handle(); return $response; // return $response->getResponseValue(); }
/** * Makes an API request and returns the result * * @param string $method * @param array $params */ public function call($method, $params) { $this->_request->setMethod($method); $this->_request->setParams($params); try { $return = $this->_internalClient->cosmosRequest($this->_request); } catch (Exception $e) { Zend_Debug::dump($e); die; // $return = array(); // $return['request'] = $this->_internalClient->getHttpClient()->getLastRequest(); // $return['response'] = $this->_internalClient->getHttpClient()->getLastResponse(); } // $return = array(); // $return['request'] = $this->_internalClient->getHttpClient()->getLastRequest(); // $return['response'] = $this->_internalClient->getHttpClient()->getLastResponse(); return $return; }
public function cosmosRequest(Cosmos_Api_Request $request) { $this->getHttpClient()->setHeaders('Authorization', $request->getOauthHeader()); $this->doRequest($request->getNativeRequest()); return $this->getLastResponse()->getReturnValue(); }