使用此代码:
use App\Helpers\Helper;
public function send_otp(Request $request)
{
$phone = "+".$request->mobile;
$checkPhone = User::where('mobile', $phone)->first();
if(count($checkPhone) == 0) {
$six_digit_random_number = mt_rand(100000, 999999);
$message = "Your one time verification code is $six_digit_random_number";
Helper::send_twilio_sms($phone, $message);
$response_array = array('success'=>true,'code'=>$six_digit_random_number,'message'=>'OTP Code has been sent succesfully');
} else {
$response_array = array('success'=>false,'code'=>'','message'=>'The mobile number is in already use.');
}
$response = response()->json($response_array, 200);
return $response;
}
短信未发送,移动应用未收到消息。