You are here

protected function BynderConfigurationForm::testApiConnection in Bynder 8

Same name and namespace in other branches
  1. 8.3 src/Form/BynderConfigurationForm.php \Drupal\bynder\Form\BynderConfigurationForm::testApiConnection()
  2. 8.2 src/Form/BynderConfigurationForm.php \Drupal\bynder\Form\BynderConfigurationForm::testApiConnection()
  3. 4.0.x src/Form/BynderConfigurationForm.php \Drupal\bynder\Form\BynderConfigurationForm::testApiConnection()

Tests connection with the Bynder API.

Parameters

string $consumer_key: Consumer key.

string $consumer_secret: Consumer secret.

string $token: Token.

string $token_secret: Token secret.

string $account_domain: Account domain.

Return value

bool Whether communication was successfully established.

2 calls to BynderConfigurationForm::testApiConnection()
BynderConfigurationForm::testConnectionAjaxCallback in src/Form/BynderConfigurationForm.php
AJAX callback for test connection button.
BynderConfigurationForm::validateForm in src/Form/BynderConfigurationForm.php
Form validation handler.

File

src/Form/BynderConfigurationForm.php, line 455

Class

BynderConfigurationForm
Configure bynder to enable OAuth based access.

Namespace

Drupal\bynder\Form

Code

protected function testApiConnection($consumer_key, $consumer_secret, $token, $token_secret, $account_domain) {
  try {
    $this->bynder
      ->setBynderConfiguration([
      'consumerKey' => $consumer_key,
      'consumerSecret' => $consumer_secret,
      'token' => $token,
      'tokenSecret' => $token_secret,
      'baseUrl' => $account_domain,
    ]);
    $this->bynder
      ->getBrands();
  } catch (\Exception $exception) {
    return FALSE;
  }
  return TRUE;
}