Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

send sms

Questions related to using nuBuilder Forte.
Locked
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

send sms

Unread post 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.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: send sms

Unread post 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
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: send sms

Unread post 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
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: send sms

Unread post by admin »

.
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

Re: send sms

Unread post by amit »

Wow, that's great. It works perfectly.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: send sms

Unread post by admin »

.
Locked