How do I get SMS on my phone when someone fill a form in my website?

How do I get SMS on my phone when someone fill a form in my website? by Quora

Answer by Rahul Am:

Hello,

This is pretty SIMPLE,
You can implement it with any Messaging Gateway Provider.

Messaging gateway providers typically offer HTTP or REST APIs for sending SMS, which can be integrated into your application easily.


Where To Integrate:

You must be having an ‘action’ attribute inside <form> tag where path to server side program is written, so that form data can be POSTED to action script when user submits the form.

OR

If you are using Ajax, your JS code might be capturing form data and later posting it to remote / local URL

SMS API must be integrated within the server side program, where form data is captured and further processed (Ex. Inserted to DB Or sent over email )


How To Integrate:

SMS Sending APIs typically input 3 parameters

– To whom message needs to be sent
– With what name message needs to be sent ( Sender Id )
– What text needs to be sent

We at 2Factor – Messaging Service Provider, have simplified Text sending via API as below ( sample code provided below is in PHP )

<?php

$YourAPIKey='<YourAPIKey>'; # Received from 2Factor.in
$From='<SenderId>';
$To='<PhoneNumber>';
$Msg='<YourMessage>';


### DO NOT Change anything below this line
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$url = "https://2factor.in/API/V1/$YourAPIKey/ADDON_SERVICES/SEND/TSMS"; 
$ch = curl_init(); 
curl_setopt($ch,CURLOPT_URL,$url); 
curl_setopt($ch,CURLOPT_POST,true); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
curl_setopt($ch,CURLOPT_POSTFIELDS,"From=$From&To=$To&Msg=$Msg"); 
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
echo curl_exec($ch); 
curl_close($ch);

In above sample code, You are required to change only 4 lines

  • $YourAPIKey: API Key provided by 2Factor.in
  • $From: name with which SMS must go
  • $To: Phone number of the user ( your own number in this case )
  • $Msg: You can collect form data and append it to this parameter

If you need further assistance, Feel free to reach us at 2Factor.in OR drop us an email at support@2factor.in

References: 2Factor SMS Sending API ( Documentation )
2Factor Website

How do I get SMS on my phone when someone fill a form in my website?