You are here

public static function SendinblueManager::updateAccessToken in SendinBlue 7

Same name and namespace in other branches
  1. 7.2 includes/sendinblue.manage.inc \SendinblueManager::updateAccessToken()

Update access token.

Return value

string An access token information.

3 calls to SendinblueManager::updateAccessToken()
SendinblueManager::generateCampaignLogin in includes/sendinblue.manage.inc
Generate Campaign page when log in.
SendinblueManager::generateListLogin in includes/sendinblue.manage.inc
Generate List page when log in.
SendinblueManager::generateStatisticLogin in includes/sendinblue.manage.inc
Generate Statistic page when log in.

File

includes/sendinblue.manage.inc, line 229
Manage class file.

Class

SendinblueManager
Basic manager of module.

Code

public static function updateAccessToken() {
  $access_key = variable_get(self::ACCESS_KEY, '');
  $mailin = new SendinblueMailin(self::API_URL, $access_key);

  // If exist old access_token, delete it.
  $old_access_token = variable_get(self::ACCESS_TOKEN, '');
  $mailin
    ->deleteToken($old_access_token);

  // Get new access_token.
  $access_response = $mailin
    ->getAccessTokens();
  $access_token = $access_response['data']['access_token'];
  variable_set(self::ACCESS_TOKEN, $access_token);
  return $access_token;
}