PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Feb 23, 2018 11:01 pm

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 
Offline
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.

<?php

$con = mysqli_connect("127.0.0.1","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 = "";
$nid="";
$post_url = 'http://89.234.44.228:8080/httpbroker';

$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\">
<message
id=\"1\"
msisdn=\"$number\"
service-number=\"$SCode\"
operator=\"\"
defer-date=\"\"
validity-period=\"7\"
priority=\"1\"><content type=\"text/plain\">$msg</content>
</message>
</bulk-request>";

$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));

}
curl_close($ch);
}
}

?>


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

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


Top
 Profile  
 
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: Majestic-12 [Bot] and 18 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