You are here

protected function TfaBasicSms::sendCode in TFA Basic plugins 7

Send the code via the client.

Parameters

string $code:

Return value

bool

3 calls to TfaBasicSms::sendCode()
TfaBasicSms::begin in includes/tfa_sms.inc
TFA process begin.
TfaBasicSms::submitForm in includes/tfa_sms.inc
Submit form.
TfaBasicSmsSetup::begin in includes/tfa_sms.inc
TFA process begin.

File

includes/tfa_sms.inc, line 142

Class

TfaBasicSms

Code

protected function sendCode($code) {
  $to = $this
    ->getAccountNumber();
  try {
    $message = $this->client->account->messages
      ->sendMessage($this->twilioNumber, $to, t($this->messageText, array(
      '!code' => $code,
    )));

    // @todo Consider storing date_sent or date_updated to inform user.
    watchdog('tfa_basic', 'Message !id sent to user !uid on @sent', array(
      '@sent' => $message->date_sent,
      '!id' => $message->sid,
      '!uid' => $this->context['uid'],
    ), WATCHDOG_INFO);
    return TRUE;
  } catch (Services_Twilio_RestException $e) {
    watchdog('tfa_basic', 'Twilio send message error to user !uid. Status code: @code, message: @message, link: @link', array(
      '!uid' => $this->context['uid'],
      '@code' => $e
        ->getStatus(),
      '@message' => $e
        ->getMessage(),
      '@link' => $e
        ->getInfo(),
    ), WATCHDOG_ERROR);
    return FALSE;
  }
}