You are here

public function SimpleFbConnectFbFactory::getFbService in Simple FB Connect 8.3

Returns an instance of Facebook\Facebook service.

Reads Facebook App ID and App Secret from SimpleFbConnect module settings and creates an instance of Facebook service with these as parameters.

Return value

\Facebook\Facebook Facebook service instance.

File

src/SimpleFbConnectFbFactory.php, line 45

Class

SimpleFbConnectFbFactory
Class SimpleFbConnectFbFactory.

Namespace

Drupal\simple_fb_connect

Code

public function getFbService() {

  // Check that App ID and secret have been defined in module settings.
  if ($this
    ->validateConfig()) {
    $sdk_config = [
      'app_id' => $this
        ->getAppId(),
      'app_secret' => $this
        ->getAppSecret(),
      'default_graph_version' => $this
        ->getApiVersion(),
      'persistent_data_handler' => $this->persistentDataHandler,
      'http_client_handler' => $this
        ->getHttpClient(),
    ];
    return new Facebook($sdk_config);
  }

  // Return FALSE if app ID or secret is missing.
  return FALSE;
}