You are here

function mobile_number_resource_verify_number in Mobile Number 7

Verifies a mobile number.

Parameters

string $number: The phone number to verify.

string $country: (optional) The two-letter country code of the mobile number. Can be NULL if the country is implied in the number.

string $code: The code that was sent to the mobile number.

string $verification_token: The token generated to go with the code.

Return value

boolean TRUE on success, FALSE on failure.

1 string reference to 'mobile_number_resource_verify_number'
mobile_number_services_resources in ./mobile_number.module
Implements hook_services_resources().

File

include/mobile_number.resources.inc, line 52

Code

function mobile_number_resource_verify_number($number, $country = NULL, $code, $verification_token = NULL) {
  try {
    $mobile_number = new MobileNumber($number, $country);
    if (!$mobile_number
      ->checkFlood()) {
      return services_error(t('Too many attempts, try again later.'), 406);
    }
    else {
      return $mobile_number
        ->verifyCode($code, $verification_token);
    }
  } catch (Exception $e) {
    return services_error($e
      ->getMessage(), 406);
  }
}