问题描述
我有一个短信队列表,该表临时保存来自不同用户的预定短信,我运行cron来检查队列中是否有任何消息,如果有则发送它们。每个短信都应使用专门针对单个用户的短信令牌。在下面的代码中,我无法实现这一点,它没有发送一条消息,而是多次发送同一条消息,具体取决于在sms队列表中找到的令牌数量。如何确保$instace
仅将特定的消息和用户令牌传递给sendBatchSms函数,而不是发送多个短信并从每个用户帐户中多次消费短信单位?
$query_sch = "SELECT * FROM crbsms_queue
LEFT JOIN crbusers ON crbsms_queue.user_id = crbusers.user_id";
$sch_result = MysqLi_query($MysqLi,$query_sch);
foreach($sch_result as $value)
{
$phone = $value['phones'];
$sender = $value['sender'];
$message = $value['message'];
$user_id = $value['user_id'];
$id = $value['id'];
$token = $value["access_token"];
$link_id = NULL;
$correlator = "$id";
$endpoint = 'https://example.com/delivery-url.PHP';
$version = "v1"; //DONT change unless you are using a different version
$instance = new BongaTech($token,$version);
$list[] = new Sms($sender,$phone,$message,$correlator,null,$endpoint);
if($list !== null){
$row_chunks = array_chunk($list,100);
////////here we have 100 messages on each chunk
///////Loop through the messages in side the chunk
foreach ($row_chunks as $sms){
$response = call_user_func_array(array($instance,"sendBatchSMS"),$sms);
}// close chunk
}//if not null
}//close results MysqLi
$response = json_encode($response,true);
$results = json_decode($response,true);
print_r($response);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)