web.php
Route::get('/sendsms','SmsController@sendSms')->name('sendsms'); //loading sms form Route::post('/sendmessage','SmsController@sendMessage')->name('sendmessage'); //submitting sms form data
Controller SmsController
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class SmsController extends Controller{ public function sendSms(){ return view('sendsms');} public function sendMessage(Request $request) { $api_url = "http://api.sparrowsms.com/v2/sms/?". http_build_query(array( 'token' => 'e84KLAlrt4BfsBhlL13E', 'from' => 'DEMO', 'to' => $request->input('phone_number'), 'text' => $request->input('message'))); $response = file_get_contents($api_url); dd($response); }}
Sendsms.blade
@extends('layouts.back_master')@section('javascript') <script type="text/javascript" src="{{asset('assets/jqueryvalidation/dist/jquery.validate.min.js')}}"></script> <script type="text/javascript"> $(document).ready(function () { $('#sms_form').validate(); }); </script> @endsection @section('content') <div class="container"> <div class="row"> <div class="col-md-12"> <div class="panel panel-default"> <div class="panel-heading"> <label>SMS Form</label> </div> <div class="panel-body"> <form action="{{route('sendmessage')}}" method="post" enctype="multipart/form-data" id="sms_form"> {{ csrf_field() }} <div class="form-group"> <label for="phone_number"> Phone Number</label> <input type="number" class="form-control" name="phone_number" id="phone_number" required> </div> <div class="form-group"> <label for="message">Message</label> <textarea class="form-control" name="message" id="message" required></textarea> </div> <div class="form-group"> <input class="btn btn-success" type ="submit" name ="submit" value="Send SMS"> </div> </form> </div> </div> </div> </div> </div> @endsection
Comments
Post a Comment