Welcome to the nuBuilder Forums!

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

SMS

Questions related to using nuBuilder Forte.
Locked
ajay
Posts: 38
Joined: Wed May 16, 2018 1:01 pm

SMS

Unread post by ajay »

I want to send SMS to my customers, have SMS gateway AuthKey and integration code,
i have entered code in Before Save, but when i am clicking on save, there are many errors ??
You do not have the required permissions to view the files attached to this post.
ajay
Posts: 38
Joined: Wed May 16, 2018 1:01 pm

Re: SMS

Unread post by ajay »

sample code:

<?php

//Your authentication key
$authKey = "YourAuthKey";

//Multiple mobiles numbers separated by comma
$mobileNumber = "9999999";

//Sender ID,While using route4 sender id should be 6 characters long.
$senderId = "102234";

//Your message to send, Add URL encoding here.
$message = urlencode("Test message");

//Define route
$route = "default";
//Prepare you post parameters
$postData = array(
'authkey' => $authKey,
'mobiles' => $mobileNumber,
'message' => $message,
'sender' => $senderId,
'route' => $route
);

//API URL
$url="http://api.msg91.com/api/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;
?>
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: SMS

Unread post by toms »

Remove the php tags and echo() functions to show information. Use nuDebug() to output information in the debug log. And use nuDisplayError() to display an error message.

Code: Select all

nuDebug($output);//Your authentication key
$authKey = "YourAuthKey";

//Multiple mobiles numbers separated by comma
$mobileNumber = "9999999";

//Sender ID,While using route4 sender id should be 6 characters long.
$senderId = "102234";

//Your message to send, Add URL encoding here.
$message = urlencode("Test message");

//Define route 
$route = "default";
//Prepare you post parameters
$postData = array(
    'authkey' => $authKey,
    'mobiles' => $mobileNumber,
    'message' => $message,
    'sender' => $senderId,
    'route' => $route
);

//API URL
$url = "http://api.msg91.com/api/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)) {
    nuDisplayError('error:'.curl_error($ch));
}

curl_close($ch);

//echo $output;
ajay
Posts: 38
Joined: Wed May 16, 2018 1:01 pm

Re: SMS

Unread post by ajay »

thanks :D
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: SMS

Unread post by admin »

.
Locked