You are here

public static function SiteimproveUtils::requestToken in Siteimprove 7

Return Siteimprove token.

2 calls to SiteimproveUtils::requestToken()
siteimprove_admin_settings_form_ajax_request_token in ./siteimprove.admin.inc
Ajax callback function for requesting a new Siteimprove token.
siteimprove_install in ./siteimprove.install
Implements hook_install().

File

includes/SiteimproveUtils.php, line 19
Utils for Siteimprove Plugin.

Class

SiteimproveUtils
Class SiteimproveUtils.

Code

public static function requestToken() {

  // Request new token.
  $headers = array(
    'Accept' => 'application/json',
  );
  $result = drupal_http_request(self::getTokenRequestUrl(), array(
    'headers' => $headers,
  ));

  // If success, set token field with the new token.
  if ($result->code == 200) {
    $json = json_decode($result->data);
    if (!empty($json->token)) {
      return $json->token;
    }
  }
  watchdog('siteimprove', 'There was an error requesting a new token.', array(), WATCHDOG_ERROR);
  return FALSE;
}