'laravel bulk sms notification sending

hello I'm new for laravel I'm trying to send SMS notification from api.

I'm using 3rd party service for sending sms thy have less documentation for php code integration. and API URL

When I tried in laravel form controller when form submit sms notification will triggers by this but problem is my API User name and passwords displayed in browser URL and inspect network tab too is was problem I don't want to show my API Credentials to any one

return redirect()->away("http://api.bulksmsgateway.in/sendmessage.php?user=....&password=.......&mobile=........&message=hello&sender=.......&type=3&template_id=123"); 

** php code integration service provider document**

<?php
error_reporting (E_ALL ^ E_NOTICE);
$username="XXXXXXX";
$password ="XXXXXXX";
$number=$_POST['number'];
$sender="abc";
$message=$_POST['message'];
$template_id='12345';
if($_POST['submitted']=='true')
{ 
$url="http://api.bulksmsgateway.in/sendmessage.php?user=".urlencode($username)."&password=".urlencode($password)."&mobile=".urlencode($number)."&sender=".urlencode($sender)."&message=".urlencode($message)."&type=".urlencode('3')."&template_id=".urlencode($template_id);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo $curl_scraped_page = curl_exec($ch);
curl_close($ch); 
}

?>
<html>
<head>
</head>
<body>
<form action="" method="post" name="sms_gate" >
<br />
Number : <br />
<input type="text" name="number" />
<br /><br />
Message:<br/>
<textarea name="message" ></textarea>
<input type="hidden" name="submitted" value="true" />
<br />
<input type="submit" name="submit" value="send" />
</form>
</body>
</html>

** API URL code integration service provider document provided this**

URL : http://api.bulksmsgateway.in/sendmessage.php?user=....&password=.......&mobile=........&message=hello&sender=.......&type=3&template_id=123

my controller

public function Store_Enrollment(Request $request)

    {

      $this->validate($request, [

  'student_name' => 'required|string|max:255',
  'student_phone_no' => 'required|string|max:10',
         
    ]);
 
   $input['student_name'] = ucfirst ($request['student_name']);
   $input['student_phone_no'] = $request->student_phone_no;
   $redirect = Student::create($input); 
 
  
return redirect()->away("http://api.bulksmsgateway.in/sendmessage.php?user=XXX&password=XXX&mobile=$redirect->student_phone_no&message=Dear  $redirect->student_name,  G&sender=ABC&type=3&template_id=112"); 

}


Solution 1:[1]

In my case, I use Laravel Trait and guzzlehttp/guzzle Package to send bulk sms. The steps I did was something like below

i) I installed guzzlehttp/guzzle Package. Associated documentation is https://laravel.com/docs/8.x/http-client.

ii) I created Laravel trait class. Inside the trait class, I write a method to send SMS. I use CURL to call the third party SMS API.

iii) In the controller I import the Trait class and call the SMS sending trait method from there.

I hope this steps help.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Phan Hero