You are here

public function FacebookAuthManager::requestEndPoint in Social Auth Facebook 3.x

Same name and namespace in other branches
  1. 8.2 src/FacebookAuthManager.php \Drupal\social_auth_facebook\FacebookAuthManager::requestEndPoint()

Request and end point.

Parameters

string $method: The HTTP method for the request.

string $path: The path to request.

string|null $domain: The domain to request.

array $options: Request options.

Return value

array|mixed Data returned by provider.

Overrides OAuth2ManagerInterface::requestEndPoint

File

src/FacebookAuthManager.php, line 98

Class

FacebookAuthManager
Contains all the logic for Facebook OAuth2 authentication.

Namespace

Drupal\social_auth_facebook

Code

public function requestEndPoint($method, $path, $domain = NULL, array $options = []) {
  if (!$domain) {
    $domain = 'https://graph.facebook.com';
  }
  $url = $domain . '/v' . $this->settings
    ->get('graph_version') . $path;
  $url .= '&access_token=' . $this
    ->getAccessToken();
  try {
    $request = $this->client
      ->getAuthenticatedRequest($method, $url, $this
      ->getAccessToken(), $options);
  } catch (\Exception $e) {
    watchdog_exception('social_auth_facebook', $e);
    return NULL;
  }
  try {
    return $this->client
      ->getParsedResponse($request);
  } catch (IdentityProviderException $e) {
    $this->loggerFactory
      ->get('social_auth_facebook')
      ->error('There was an error when requesting ' . $url . '. Exception: ' . $e
      ->getMessage());
  }
  return NULL;
}