You are here

public function TwitterAuth::initSdk in Open Social 8.2

Same name and namespace in other branches
  1. 8.9 modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php \Drupal\social_auth_twitter\Plugin\Network\TwitterAuth::initSdk()
  2. 8 modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php \Drupal\social_auth_twitter\Plugin\Network\TwitterAuth::initSdk()
  3. 8.3 modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php \Drupal\social_auth_twitter\Plugin\Network\TwitterAuth::initSdk()
  4. 8.4 modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php \Drupal\social_auth_twitter\Plugin\Network\TwitterAuth::initSdk()
  5. 8.5 modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php \Drupal\social_auth_twitter\Plugin\Network\TwitterAuth::initSdk()
  6. 8.6 modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php \Drupal\social_auth_twitter\Plugin\Network\TwitterAuth::initSdk()
  7. 8.7 modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php \Drupal\social_auth_twitter\Plugin\Network\TwitterAuth::initSdk()
  8. 8.8 modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php \Drupal\social_auth_twitter\Plugin\Network\TwitterAuth::initSdk()

File

modules/custom/social_auth_twitter/src/Plugin/Network/TwitterAuth.php, line 58

Class

TwitterAuth
Defines Social Auth Twitter Network Plugin.

Namespace

Drupal\social_auth_twitter\Plugin\Network

Code

public function initSdk() {
  $class_name = '\\Abraham\\TwitterOAuth\\TwitterOAuth';
  if (!class_exists($class_name)) {
    throw new SocialApiException(sprintf('The PHP SDK for Twitter Client could not be found. Class: %s.', $class_name));
  }

  /* @var \Drupal\social_auth_twitter\Settings\TwitterAuthSettings $settings */
  $settings = $this->settings;
  if (!$this
    ->validateConfig($settings)) {
    return FALSE;
  }

  // Creates a and sets data to TwitterOAuth object.
  return new $class_name($settings
    ->getConsumerKey(), $settings
    ->getConsumerSecret());
}