We want to send a SMS to our Visitors when a Form is Submitted

  • Profile Image
    gurgaonhigh
    Asked on October 08, 2013 at 05:52 AM

    Hi,

    We want to send a Thankyou SMS to our Visitors when a Form is Submitted on our website.

    Our Serive Provider has provided is with their API (https://control.msg91.com/sendhttp.php?user=58576&password=password&mobiles=9999999999&message=message&sender=senderid)

    But how do we extract dynamic fields like name, number etc and put them in this URL. Please help.

     

    Thanks, Vivek

  • Profile Image
    EltonCris
    Answered on October 08, 2013 at 06:28 AM

    Hi Vivik,

    You can use Webhook to achieve that, but you have to write a custom script in order to fire up the SMS when the form is submitted. Don't you worry, you can try my sample script. Follow these steps.

    1. Copy this script: http://pastebin.com/embed_iframe/0A558v0y 

    2. Change the value like username, pass and sender on the script.

    3. Save it as PHP file (with .php extension e.g. sms.php)

    4. Upload that PHP file to your server

    5. Get the PHP file URL and set it as your form's Webhook. Guide: Creating your first Webhook with JotForm

    Let us know if you encounter any issues. Thanks!

  • Profile Image
    poopselfie
    Answered on February 16, 2014 at 06:18 PM

    Not sure how this works, I would be totally interested in figuring this out. I've uploaded a new file called sms.php to my server and changed the username, pass, and sender. Now how do I get a notification to send to the mobile number specified in my form?

  • Profile Image
    ashwin_d
    Answered on February 16, 2014 at 09:37 PM

    Hello poopselfie,

    You need to grab the file url of sms.php and set it up as your webhook. It will fire the php code when your form is submitted. The following guide should help you:  http://www.jotform.me/help/245-Creating-your-first-Webhook-with-JotForm

    DO get back to us if you have any questions.

    Thank you!

  • Profile Image
    poopselfie
    Answered on February 16, 2014 at 10:22 PM

    Not sure what I'm doing wrong, ashwin_d,

    Probably something so simple.

    Just to make things clear; "user" and "password" are my jotfrom username and password?

    //Create the SMS URL

    $url = 'https://control.msg91.com/sendhttp.php?' . http_build_query(array(

        'user' => "12345",

        'password' => "your pass here",

        'mobiles' => $mobile,

        'message' => $message,

        'sender' => "your sender here",

        'name' => $name,

    ///... continue

    ));

    and "mobiles" "message" "sender" and "name" are whatever variables I have set in my form for those inputs?

     

    My apologies again, I am just trying to make this go smoothly.

  • Profile Image
    ashwin_d
    Answered on February 17, 2014 at 03:04 AM

    Hello poopselfie,

    If I am not wrong, the user name and password should be the login credentials of your msg91.com account. If you have not signed up already, please use the following URL to sign up for an account: http://www.msg91.com

    Rest of the information seems to be correct.

    Do test and get back to us if you have any questions.

    Thank you!

  • Profile Image
    sodesignin
    Answered on July 18, 2014 at 10:00 AM

    I have entered as you said in the before form 

    i entered my API Url and Enter my username and password in the field but where to enter my mobile number to receive text , Can you help ?

  • Profile Image
    david
    Answered on July 18, 2014 at 11:51 AM

    Hi,

    The mobile number would be grabbed from the form form.  If you look in the script, the variable $mobile is mapped to the field "q4_mobile" which would relate to the 4th field in the form labeled "mobile".  You would not be entering anything in the script as this is where it gets the mobile number to send the text to.

    Please let us know if you have any other questions and we will be happy to help.

    Thank you for using Jotform!

  • Profile Image
    sodesignin
    Answered on July 18, 2014 at 09:29 PM

    This is the script i hooked to my jot form check it & and if any wrong pl mention it

    ------------------------------------------

    <?php

     

    //Strips all slashes in an array

    function stripslashes_deep($value){

        $value = is_array($value) ?

                    array_map('stripslashes_deep', $value) :

                    stripslashes($value);

        return $value;

    }

     

    $result = stripslashes_deep($_REQUEST['rawRequest']);

    $obj = json_decode($result, true);

     

    $name = $obj['q1_name']; //name

    $mobile = $obj['here i entered my mobile number']; //mobile

    $message = $obj['q5_comments']; //msg

     

    //Create the SMS URL

    $url = 'http://smshorizon.co.in/api/sendsms.php?' . http_build_query(array(

        'user' => "My username ",

        'password' => "My password",

        'mobiles' => $mobile,

        'message' => $message,

        'sender' => "WEBSIT", 

        'name' => $name,

    ///... continue

    ));

     

    //cURL - load the URL

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_HEADER, 0);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $content = trim(curl_exec($ch));

    curl_close($ch);

     

    ?>         

  • Profile Image
    ashwin_d
    Answered on July 19, 2014 at 05:08 AM

    Hello sodesignin,

    I am not sure if I have understood the workflow you your requirement. Are you reading the mobile number value form your form or you are hard coding your mobile number in your script, the syntax you mentioned above seems to be not correct:

    $mobile = $obj['here i entered my mobile number']; //mobile - If you input your mobile number between the '' here, the script will look for a variable / field name as your mobile number.

    If you are hard coding your mobile number you can replace the above line in your script with the following code :

    $mobile = "Input your mobile number here"; //mobile

     

    Or you can also directly input your mobile number where you are creating SMS URL in your script:

    //Create the SMS URL

    $url = 'http://smshorizon.co.in/api/sendsms.php?' . http_build_query(array(

        'user' => "My username ",

       'password' => "My password",

        'mobiles' => "Input your mobile number here",

        'message' => $message,

        'sender' => "WEBSIT", 

        'name' => $name,

    ///... continue

    ));

    Try this out and get back to us if you have any questions.

    Thank you!

  • Profile Image
    Zinfomatic 
    Answered on April 22, 2015 at 04:28 AM
  • Profile Image
    ashwin_d
    Answered on April 22, 2015 at 06:01 AM

    Hello Zinfomatic,

    Thank you for sharing it with us. It will be useful for lot of users.

    Thank you!

  • Profile Image
    tlwbangalore
    Answered on May 05, 2015 at 10:23 AM

    Hi EltonCris

    I have done all the things you said. Still its not working. Just tell me one thing.
    $result = $_REQUEST['rawRequest']);
    In this line what is '
    rawRequest' ? submit button name  or form name ?

  • Profile Image
    tlwbangalore
    Answered on May 05, 2015 at 11:05 AM

    $result = $_REQUEST['rawRequest']);
    $obj = json_decode($result, true);

    $name = $obj['{input11}']; //name
    $mobile = $obj['{phoneNumber22}']; //mobile
    $message = $obj['test']; //msg

    //Create the SMS URL
    $url = 'http://alerts.sinfini.com/api/web2sms.php?'.http_build_query(array(
        'workingkey' => "xxxxxxxxxxxxxxxxxxxxxx",
        'to' => $mobile,
        'sender' => "XXXXXXXXXXXX",
        'message' => $message
    ));

    //cURL - load the URL
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $content = trim(curl_exec($ch));
    curl_close($ch);

    ?>

    this is the code i am using

  • Profile Image
    ashwin_d
    Answered on May 05, 2015 at 11:10 AM

    Hello tlwbangalore,

    I did check the code shared by my colleague. This is a very old thread and it seems the "rawRequest" is deprecated.

    I am not a PHP programmer but if I understand the code correctly, the rawRequest was used to get all the post data form your form. Please check the following URL on how to read the post data:  http://php.net/manual/en/reserved.variables.httprawpostdata.php 

    Hope this helps.

    I have also asked my colleague @EltonChris to look into this thread.

    Thank you!

  • Profile Image
    Jason MArtin 
    Answered on October 30, 2015 at 03:35 AM

    I know nothing about code however sometimes i can make out what its doing. Please give me a step by step guide, using google forms as a form. I need sms to be sent to users.

     

    Thanks

  • Profile Image
    sacredvibes
    Answered on January 22, 2016 at 04:51 PM

    This is What I have made for my site. I am not seeing any API Requests on the Backend of the msg91 panel.

    Please help me out. :)

     

    <?php

    //strip off slashes

    function stripslashes_deep($value){

        $value = is_array($value) ?

                    array_map('stripslashes_deep', $value) :

                    stripslashes($value);

        return $value;

    }

     

    //Get form field values

    $result = stripslashes_deep($_REQUEST['rawRequest']);

    $obj = json_decode($result, true);

     

    //Authentication key & default values

    $authKey = "xxxxxxxxxxxx";

    $senderId = “iAlert”;

    $route = "default";

     

    //replace your form field names

    $mobileNumber = 91$obj['phoneNumber']; //mobile no. from form data

    $message = urlencode(Dear $obj['fullName3'] Thnkx for signing up. ur Passes have been mailed to $obj['email'] ); //message from form data

     

     

    //Prepare you post parameters

    $postData = array(

        'authkey' => $authKey,

        'mobiles' => $mobileNumber,

        'message' => $message,

        'sender' => $senderId,

        'route' => $route

    );

     

    //Replace your API URL

    $url="https://control.msg91.com/sendhttp.php";

     

    // init the resource

    $ch = curl_init();

    curl_setopt_array($ch, array(

        CURLOPT_URL => $url,

        CURLOPT_RETURNTRANSFER => true,

        CURLOPT_POST => true,

        CURLOPT_POSTFIELDS => $postData

        //,CURLOPT_FOLLOWLOCATION => true

    ));

     

    //Ignore SSL certificate verification

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

     

    //get response

    $output = curl_exec($ch);

     

    //Print error if any

    if(curl_errno($ch))

    {

        echo 'error:' . curl_error($ch);

    }

     

    curl_close($ch);

    echo $output;

    ?>

  • Profile Image
    Kevin_G
    Answered on January 22, 2016 at 06:40 PM

    Hi,

    Please, make sure you have integrated your form with Webhooks, then you may follow the example on this link.

    Then you should get the correct info for the API.

    You should replace that info on the code that is provided on the link I shared above, on this script.

  • Profile Image
    sacredvibes
    Answered on January 22, 2016 at 10:14 PM

    This is What I have made for my site. I am not seeing any API Requests on the Backend of the msg91 panel.

    Please help me out. :)

     

    <?php

    //strip off slashes

    function stripslashes_deep($value){

        $value = is_array($value) ?

                    array_map('stripslashes_deep', $value) :

                    stripslashes($value);

        return $value;

    }

     

    //Get form field values

    $result = stripslashes_deep($_REQUEST['rawRequest']);

    $obj = json_decode($result, true);

     

    //Authentication key & default values

    $authKey = "xxxxxxxxxxxx";

    $senderId = “iAlert”;

    $route = "default";

     

    //replace your form field names

    $mobileNumber = 91$obj['phoneNumber']; //mobile no. from form data

    $message = urlencode(Dear $obj['fullName3'] Thnkx for signing up. ur Passes have been mailed to $obj['email'] ); //message from form data

     

     

    //Prepare you post parameters

    $postData = array(

        'authkey' => $authKey,

        'mobiles' => $mobileNumber,

        'message' => $message,

        'sender' => $senderId,

        'route' => $route

    );

     

    //Replace your API URL

    $url="https://control.msg91.com/sendhttp.php";

     

    // init the resource

    $ch = curl_init();

    curl_setopt_array($ch, array(

        CURLOPT_URL => $url,

        CURLOPT_RETURNTRANSFER => true,

        CURLOPT_POST => true,

        CURLOPT_POSTFIELDS => $postData

        //,CURLOPT_FOLLOWLOCATION => true

    ));

     

    //Ignore SSL certificate verification

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

     

    //get response

    $output = curl_exec($ch);

     

    //Print error if any

    if(curl_errno($ch))

    {

        echo 'error:' . curl_error($ch);

    }

     

    curl_close($ch);

    echo $output;

    ?>

  • Profile Image
    sacredvibes
    Answered on January 22, 2016 at 10:43 PM

    Hi @Kevin_G

    I've integrated my form with webhooks pointing to the php file hosted on my server.

    Please note that I provided the SSL Link to that file.

    Thanks so much. :)

  • Profile Image
    Kevin_G
    Answered on January 22, 2016 at 11:53 PM

    Hi @sacredvibes,

    I have moved this to another thread, this is in order to avoid any confusion and to assist you better, you will find it on this link : http://www.jotform.com/answers/753954 

    We will assist you there.

    Thank You.

  • Profile Image
    Sumerasumera 
    Answered on January 29, 2016 at 05:59 PM

    <?php
    $username = 'username';
    $password = 'password';
    $to = '44xxxxxxxx';
    $from = 'Brand';
    $message = 'Test SMS from Lifetimesms.com';
    $url = "http://Lifetimesms.com/plain?username=".$username."&password=".$password.
    "&to=" .$to"&from=".urlencode($from)."&message=".urlencode($message)." ";
    //Curl Start
    $ch curl_init();
    $timeout 30;
    curl_setopt ($ch,CURLOPT_URL$url) ;
    curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, $timeout) ;
    $response curl_exec($ch) ;
    curl_close($ch) ; 
    //Write out the response
    echo $response ;
    ?> i want to put this code in form in such a way that only number variable will use to add number all the detail that i add in user paswrd not visible to other how itcn be implemnt

  • Profile Image
    tom 
    Answered on February 13, 2016 at 07:35 PM

    can someone set one of these up for me? I will pay them

  • Profile Image
    Kevin_G
    Answered on February 13, 2016 at 10:36 PM

    @Tom,

    Unfortunately, we can not do that, you may find someone to do it here: https://www.upwork.com.

     

  • Profile Image
    Rishi Kumar 
    Answered on April 28, 2017 at 05:23 AM

    You will be use Bulk SMS API provided by PRP Services Private Limited

     

    https://www.prpsms.co.in/API/SendMsg.aspx?uname=xxxxxxxx&pass=xxxxx&send=xxxxxx& dest=xxxxxxxxxx&msg=xxxxxxx&priority=1&schtm=xxxx-xx-xx xx:xx

     

    Error Code Description:

    0x200 Invalid User Id / Password

    0x003  Invalid message. Message does not match with approved template

    0x003  Masking not mapped with your account.

     

    Detail of query parameters:

     

    uname                      =       user name/profile id given to in the time of account                                                    creation

    pass                          =      password of your respective user account

    send                          =      Sender id approved for your account if your account                                                  is of promotional type you have to give PROMO as                                                    sender id

    dest                           =      it contains mobile no to which you want to send                                                         message

    msg                           =      it contains message which you wish to send on                                                          mobile no

    priority (Optional)       =      it should be 1

     

    schtm (Optional)         =      It contains the system data and time in which you want                                              to send SMS, it must be grater then or equal to current                                              system date and time. for instance it you want to send                                              message now pass current system date and time                                                      please mind you date must be in yyyy-mm- dd hh:mm                                              format and time should be in 24 hours clock format

     

  • Profile Image
    Aalina 
    Answered on June 04, 2017 at 06:41 AM

    <?php

    $username = 'username';
    $password = 'password';
    $to = '44xxxxxxxx';
    $from = 'Brand';
    $message = 'Test SMS from Hostandsoft.com';
    $url = "https://hostandsoft.com/api.php?username=".$username."&password=".$password.
    "&to=" .$to"&from=".urlencode($from)."&message=".urlencode($message)." ";
    //Curl Start
    $ch curl_init();
    $timeout 30;
    curl_setopt ($ch,CURLOPT_URL$url) ;
    curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, $timeout) ;
    $response curl_exec($ch) ;
    curl_close($ch) ; 
    //Write out the response
    echo $response ;
    ?>

    Detail of query parameters:

     uname                      =       user name/profile id given to in the time of account                                                    creation

     

    pass                          =      password of your respective user account

     

  • Profile Image
    Aalina 
    Answered on June 04, 2017 at 06:56 AM
    http://hostandsoft.com/api/?username=username&password=password&receiver=923001234567&msgdata=Test

     

    This is the API format I use with Host & Soft Branded SMS with PHP code above I sent