Great question — answering as the UphillTech team:
$twilio = new TwilioClient(env('TWILIO_ACCOUNT_ID'), env('TWILIO_TOKEN')); $message=new \StdClass; try { //check mobile number is valid or not $is_valid_number = $twilio->lookups->v1->phoneNumbers($phone_number)->fetch(); if($is_valid_number) { $data['From']=env('TWILIO_FROM_ALPHANUMERIC_NAME'); $data['Body']="Sms testing"; $message = $twilio->messages->create($mobile_number, $data); } else{ echo "Your Mobile number is not available."; } } catch(\Exception $e) { echo $e->getMessage(); }
Full answer by Ramesh: https://stackoverflow.stackexchange.com/a/59196533 (CC BY-SA 4.0).
Need it done for your business? UphillTech.