requestHeaders[$key] = $value; } /** * The headers returned in the response * * @return array */ public function getResponseHeaders() { return $this->responseHeaders; } /** * The HTTP status response code * * @return int */ public function getResponseHttpStatusCode() { return $this->responseHttpStatusCode; } /** * Sends a request to the server * * @param string $url The endpoint to send the request to * @param string $method The request method * @param array $parameters The key value pairs to be sent in the body * * @return string Raw response from the server * * @throws \Facebook\FacebookSDKException */ public function send($url, $method = 'GET', $parameters = array()) { $options = array(); if ($parameters) { $options = array('body' => $parameters); } $request = self::$guzzleClient->createRequest($method, $url, $options); foreach($this->requestHeaders as $k => $v) { $request->setHeader($k, $v); } try { $rawResponse = self::$guzzleClient->send($request); } catch (RequestException $e) { if ($e->getPrevious() instanceof AdapterException) { throw new FacebookSDKException($e->getMessage(), $e->getCode()); } $rawResponse = $e->getResponse(); } $this->responseHttpStatusCode = $rawResponse->getStatusCode(); $this->responseHeaders = $rawResponse->getHeaders(); return $rawResponse->getBody(); } }