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");
}
CodePudding user response:
APIs like this are intended to be called server-to-server, not in the browser.
You can use the Laravel HTTP client to make a call to this API from your server; this will not expose the API keys or other sensitive data.