function _mobile_number_request_code in Mobile Number 7
Request mobile number verification code services resource callback.
1 string reference to '_mobile_number_request_code'
- mobile_number_services_resources in ./
mobile_number.module - Implements hook_services_resources().
File
- include/
mobile_number.resources.inc, line 13
Code
function _mobile_number_request_code($number, $country = NULL) {
if (!mobile_number_sms_sending_is_enabled()) {
return services_error(t('SMS functionality not enabled.'), MobileNumber::VERIFY_SMS_FAILED);
}
try {
$mobile_number = new MobileNumber($number, $country);
if (!$mobile_number
->checkFlood('sms')) {
return services_error(t('Too many attempts, try again later.'), 406);
}
if ($token = $mobile_number
->sendVerification(MOBILE_NUMBER_DEFAULT_SMS_MESSAGE, $mobile_number
->generateVerificationCode())) {
return array(
'verification_token' => $token,
);
}
return services_error(t('Could not send verification code.'), 406);
} catch (Exception $e) {
return services_error(t($e
->getMessage()), 406);
}
}