/** * @param Api\Request $request * @param string $signatureMethodName * * @return Api\Response * * @throws Exceptions\InvalidStateException * @throws OAuth\Exceptions\ApiException */ public function makeRequest(Api\Request $request, $signatureMethodName = 'PLAINTEXT') { if (empty($this->responses)) { throw new Exceptions\InvalidStateException("Unexpected request"); } $this->requests[] = $request; $request->setHeaders($request->getHeaders() + ['Accept' => 'application/json']); // the CurlClient is setting this as a default list($content, $httpCode, $headers, $info) = array_shift($this->responses); return new Api\Response($request, $content, $httpCode, $headers, $info); }
/** * @param $ch * @param Request $request * @param $result * * @return array */ private function getRequestInfo($ch, Request $request, $result) { $info = curl_getinfo($ch); $info['http_code'] = (int) $info['http_code']; if (isset($info['request_header'])) { list($info['request_header']) = self::parseHeaders($info['request_header']); } $info['method'] = $request->getMethod() ? $request->getMethod() : 'GET'; $info['headers'] = self::parseHeaders(substr($result, 0, $info['header_size'])); $info['error'] = $result === FALSE ? ['message' => curl_error($ch), 'code' => curl_errno($ch)] : []; return $info; }
/** * @return bool */ public function isPaginated() { return $this->request->isPaginated(); }
/** * @param Api\Request $request * @param array $options */ public function begin(Api\Request $request, $options = array()) { $url = $request->getUrl(); $url->setQuery(''); $this->calls[spl_object_hash($request)] = (object) array('url' => (string) $url, 'params' => $request->getParameters(), 'options' => self::toConstantNames($options), 'result' => NULL, 'exception' => NULL, 'info' => array(), 'time' => 0); }