public static function doRequest($url, array $postData = null, $method = Request::METHOD_GET) { $client = self::getClientInstance(); $client->resetParameters(); $client->setEncType(Client::ENC_URLENCODED); $client->setUri($url); $client->setMethod($method); if ($postData === null) { $postData = array(); } $postData['access_token'] = self::getSession()->accessToken; if ($method == Request::METHOD_POST && $postData !== null) { $client->setParameterPost($postData); } if (($method == Request::METHOD_GET || $method == Request::METHOD_DELETE) && $postData !== null) { $client->setParameterGet($postData); } $response = $client->send(); if ($response->isSuccess()) { return JsonDecoder::decode($response->getBody(), Json::TYPE_ARRAY); } else { $logger = new Logger(); $logger->addWriter(new Stream('data/logs/apiclient.log')); $logger->debug($response->getBody()); return FALSE; } }
/** * @param string $method * @param string $host * @param string $path * @param array $parameters * * @return array|object */ private function http($method, $host, $path, array $parameters) { $this->resetLastResponse(); $url = sprintf('%s/%s/%s.json', $host, self::API_VERSION, $path); $this->response->setApiPath($path); $result = $this->oAuthRequest($url, $method, $parameters); $response = JsonDecoder::decode($result, $this->decodeJsonAsArray); $this->response->setBody($response); return $response; }
static function __static() { self::$parser = new JsonParser(); }