You are here

function brightcove_verify_tokens in Brightcove Video Connect 7.2

Same name and namespace in other branches
  1. 7.3 brightcove.module \brightcove_verify_tokens()
  2. 7.4 brightcove.module \brightcove_verify_tokens()
  3. 7.5 brightcove.module \brightcove_verify_tokens()

Verifies the brightcove API keys.

Parameters

string $read_token: An optional read token instead of the stored one.

string $write_token: An optional write token instead of the stored one.

Return value

array A touple of booleans as the result of the verification. The first item is TRUE if the read key is correct. The second item is TRUE if the write key is correct.

1 call to brightcove_verify_tokens()
brightcove_admin_settings_validate in ./brightcove.admin.inc

File

./brightcove.module, line 476
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function brightcove_verify_tokens($read_token = NULL, $write_token = NULL) {
  $bc = brightcove_initialize($read_token, $write_token);
  $read = FALSE;
  try {
    $read = $bc
      ->find('videobyid', 0) || TRUE;
  } catch (Exception $e) {
  }
  try {
    $bc
      ->getStatus('video', 0, 0);
    $write = TRUE;
  } catch (Exception $e) {
    $write = stripos($e
      ->getMessage(), 'token') === FALSE;
  }
  return array(
    $read,
    $write,
  );
}