Level 1
Please use phone number with your contry code , Like : '+911236584795'
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i have an issue while using twilio service for verifying phone number of the users
error: [HTTP 400] Unable to create record: Invalid parameter: To
verification controller store method
public function store(Request $request)
{
if ($request->user()->hasVerifiedPhone()) {
dd('your phone was verified already');
}
$data = $request->validate([
'phone_number' => 'required|string',
]);
$phone = $data['phone_number'];
$user_verification = auth()->user()->verification()->create([
'user_id' => auth()->id(),
'phone_number' => $phone,
]);
$verification = $this->verify->startVerification($phone, $request->post('channel', 'sms'));
if (!$verification->isValid()) {
$user_verification->delete();
$errors = new MessageBag();
foreach($verification->getErrors() as $error) {
$errors->add('verification', $error);
}
return response()->json([
'error' => $errors,
]);
}
return response()->json([
'message' => 'Your code verificaton was sent to'. $phone,
'status' => true,
]);
}
verification method:
public function startVerification($phone_number, $channel)
{
try {
$verification = $this->client->verify->v2->services($this->verification_sid)
->verifications
->create($phone_number, $channel);
return new Result($verification->sid);
} catch (TwilioException $exception) {
return new Result(["Verification failed to start: {$exception->getMessage()}"]);
}
}
any help i will be appreciated
thanks in advance.
Please or to participate in this conversation.