Page 1 of 1

send sms

Posted: Sat Jun 02, 2018 1:31 pm
by amit
Hi, new user here.
Just checking out nuBuilder's features and I wonder if it is possible to send SMS from this software? Preferably with Twilio as I have an account. Thank you.

Re: send sms

Posted: Sun Jun 03, 2018 1:33 pm
by admin
amit,

You asked...
I wonder if it is possible to send SMS from this software?
I am not sure.

All I know is, you can't from nuBuilder directly without a 3rd party API.

Steven

Re: send sms

Posted: Sun Jun 03, 2018 7:13 pm
by toms
Hi and welcome!

It's best to do this with PHP, because it won't reveal your credentials.

Add this code in the "After Save" (PHP) event of your form:
php_as.PNG

Code: Select all


// sms_to and sms_txt are fields of your form, replace them!
sendSMSTwilio("+12685555555","#sms_to#", "#sms_text#"); 

function sendSMSTwilio($from, $to, $body) {   
    $id = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";  // replace with your Account SID 
    $token = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // replace with your Auth Token.
    $url = "https://api.twilio.com/2010-04-01/Accounts/$id/Messages.json";
    
    $data = array (
        'From' => $from,
        'To' => $to,  
        'Body' => $body
    );                      
    $post = $data;
    $x = curl_init($url);
    curl_setopt($x, CURLOPT_POST, true);
    curl_setopt($x, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($x, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($x, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($x, CURLOPT_USERPWD, "$id:$token");
    curl_setopt($x, CURLOPT_POSTFIELDS, $post);
    $y = curl_exec($x);
    curl_close($x);          
    $out = explode('|', $y);         
    nuDebug($out);
}     

2. form.PNG

Re: send sms

Posted: Mon Jun 04, 2018 1:34 am
by admin
.

Re: send sms

Posted: Sun Jun 17, 2018 11:54 am
by amit
Wow, that's great. It works perfectly.

Re: send sms

Posted: Wed Jun 27, 2018 3:14 am
by admin
.