lundi 19 mars 2018

want to set exception for twilio

i am sending otp using twilio,laravel, message is working now, but i want to set exception for if message is not delivered etc i have tried like

 public function send_otp()
{

    try {
            $account_sid = env('TWILIO_ACCOUNT_SID'); 
            $auth_token = env('TWILIO_AUTH_TOKEN'); 
            $number=Auth::user()->user_phone;
            $client = new Client($account_sid, $auth_token); 
            $messages = $client->messages->create($number, array( 
                 'From' => '+12533368077',
                 'Body' => Auth::user()->user_otp,
            ));
                dd($messages);
                //return $messages;
        //throw new Exception();

  }  catch (Exception $e) {

         return response()->json(['error' => true,'message'=>'Something went wrong'],200);
 }

}

can you please help me with this



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire