You are here

public function FacebookAuthManager::requestEndPoint in Social Auth Facebook 8.2

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

File

src/FacebookAuthManager.php, line 79

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();
  $request = $this->client
    ->getAuthenticatedRequest($method, $url, $this
    ->getAccessToken(), $options);
  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;
}