baseApiUri = new Uri('https://graph.facebook.com'.$this->getApiVersionString().'/'); } } /** * {@inheritdoc} */ public function getAuthorizationEndpoint() { return new Uri('https://www.facebook.com'.$this->getApiVersionString().'/dialog/oauth'); } /** * {@inheritdoc} */ public function getAccessTokenEndpoint() { return new Uri('https://graph.facebook.com'.$this->getApiVersionString().'/oauth/access_token'); } /** * {@inheritdoc} */ protected function parseAccessTokenResponse($responseBody) { $data = @json_decode($responseBody, true); // Facebook gives us a query string on old api (v2.0) if (!$data) { parse_str($responseBody, $data); } if (null === $data || !is_array($data)) { throw new TokenResponseException('Unable to parse response.'); } elseif (isset($data['error'])) { throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); } $token = new StdOAuth2Token(); $token->setAccessToken($data['access_token']); if (isset($data['expires'])) { $token->setLifeTime($data['expires']); } if (isset($data['refresh_token'])) { $token->setRefreshToken($data['refresh_token']); unset($data['refresh_token']); } unset($data['access_token']); unset($data['expires']); $token->setExtraParams($data); return $token; } public function getDialogUri($dialogPath, array $parameters) { if (!isset($parameters['redirect_uri'])) { throw new Exception("Redirect uri is mandatory for this request"); } $parameters['app_id'] = $this->credentials->getConsumerId(); $baseUrl = self::WWW_URL .$this->getApiVersionString(). '/dialog/' . $dialogPath; $query = http_build_query($parameters); return new Uri($baseUrl . '?' . $query); } /** * {@inheritdoc} */ protected function getApiVersionString() { return empty($this->apiVersion) ? '' : '/v' . $this->apiVersion; } /** * {@inheritdoc} */ protected function getScopesDelimiter() { return ','; } }