You are here

public static function ShareaholicUtilities::api_key_verified in Share Buttons, Related Posts, Content Analytics - Shareaholic 7.3

Same name and namespace in other branches
  1. 8 utilities.php \ShareaholicUtilities::api_key_verified()

Checks whether the api key has been verified using the rails endpoint. Once the key has been verified, we store that away so that we don't have to check again.

Return value

bool

1 call to ShareaholicUtilities::api_key_verified()
ShareaholicAdmin::draw_verify_api_key in ./admin.php
This function is in charge of the logic for showing whatever it is we want to show a user about whether they have verified their api key or not.

File

./utilities.php, line 652

Class

ShareaholicUtilities

Code

public static function api_key_verified() {
  $settings = self::get_settings();
  if (isset($settings['api_key_verified']) && $settings['api_key_verified']) {
    return true;
  }
  $api_key = $settings['api_key'];
  if (!$api_key) {
    return false;
  }
  $response = drupal_http_request(self::API_URL . '/publisher_tools/' . $api_key . '/verified', array(
    'method' => 'GET',
  ));
  if (self::has_bad_response($response, 'FailedApiKeyVerified')) {
    return false;
  }
  $response = (array) $response;
  $result = $response['data'];
  if ($result == 'true') {
    ShareaholicUtilities::update_options(array(
      'api_key_verified' => true,
    ));
    return true;
  }
  return false;
}