PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
It is currently Sat Feb 16, 2019 11:36 am

All times are UTC - 5 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Schedule Code
PostPosted: Thu May 25, 2017 11:39 am 
Forum Newbie

Joined: Thu May 25, 2017 5:21 am
Posts: 1
I have problem with schedule message with gateway please, If anybody can help me
This is my code. I have two table bulk_sms_job and bulk_sms_recipient where the Job_ID in bulk_sms_job is the same Job_ID in bulk_sms_recipient.


$con = mysqli_connect("","username","passwordroot","database");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();

$td = @date('Y-m-d');
$tt = @date('H:i:00');
$ntime = @date('h:i:').'00';
$today = @date('Y-m-d H:i:00');

$nt = date('H:i:00', strtotime('+2 hours', strtotime($tt))); //+10 minutes
$ntty = date('Y-m-d H:i:00', strtotime('+10 minutes', strtotime($today)));

$query = mysqli_query($con,"SELECT j.Job_ID as jid, j.Message as msg, j.Schedule_Time as sch, r.MSISDN as msis FROM bulk_sms_job j LEFT JOIN bulk_sms_recipient r ON j.Job_ID = r.Job_ID AND r.Status = 'pending' AND j.Schedule_Time BETWEEN '{$today}' and '{$ntty}'") or die("Query to get Transaction Failed: .". mysqli_error($con));

while($resultT = mysqli_fetch_array($query)){
$jobid = $resultT['jid'];
$schd = $resultT['sch'];
$msisdns = $resultT['msis'];
$msg2 = $resultT['msg'];

$numbers = explode(",", $msisdns);
foreach($numbers as $number){
$msg = $msg2;
// send message to the gateway
$gwUser = "dkti";
$gwPass = "dkti";
$SCode = "";
$post_url = '';

$post_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><bulk-request login=\"$gwUser\" password=\"$gwPass\" ref-id=\"$nid\" delivery-notification-requested=\"true\" version=\"1.0\">
priority=\"1\"><content type=\"text/plain\">$msg</content>

$ch = curl_init($post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml;charset=UTF-8'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$post_xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$returndata = curl_exec($ch);
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE); // result=200
if ($returndata) {
// Update status in bulk_sms_recipient from pending to success
$status = "Success";

$UpdateSch = mysqli_query($con, "UPDATE bulk_sms_recipient SET Status = '{$status}' where Job_ID = '{$jobid}'") or die("Update Request status failed: .". mysqli_error($con));



 Post subject: Re: Schedule Code
PostPosted: Thu May 25, 2017 12:39 pm 
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
You haven't said what the problem is.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group