getToken(); //발송대기중인 데이터 읽어옴 while($col = mysql_fetch_array($res)) { if($col['status'] != "1") continue; //발송중으로 변경 $standby_sql = "update kakao_biztalk set status = 2 where cd_talk = '".$col['cd_talk']."' "; // echo $standby_sql; // exit; $standby_res = mysql_query($standby_sql); //업데이트 됐다면 if($standby_res) { //실제 발송 대상, 발송 데이터를 가져 온다 $recipient_sql = "select * from kakao_biztalk_recipient where cd_talk = '".$col['cd_talk']."' and status = '0'"; //and REPLACE(phone, '-', '') in ('01072393356', '01083845309', '01096690727')"; //"-- and phone = '010-7239-3356' "; //테스트 확인 용 // echo $recipient_sql; // exit; $recipient_res = mysql_query($recipient_sql); while($recipient_col = mysql_fetch_array($recipient_res)) { if($recipient_col['status'] != "0") continue; $SMS_DATA = array(); $SMS_DATA['message'] = $recipient_col['contents']; //발신 메시지 내용 (공백 포함2345 1000자로 제한) 가변 영역이 있을 경우 해당 가변 영역의 내용도 실제 보낼 내용으로 치환 되어야 한다. $SMS_DATA['recipient'] = $recipient_col['phone']; // 수신자 $SMS_DATA['senderKey'] = $col['senderKey']; // 카카오 발신 프로필 키 $SMS_DATA['tmpltCode'] = $col['tmpltCode']; // 메시지 템플릿 코드 $SMS_DATA['resMethod'] = $col['resMethod']; // 메시지 템플릿 코드 // $SMS_DATA['debug'] = "Y"; // 디버그 // print_r($SMS_DATA); // exit; $send_reuslt = $biztalk->sendSms($SMS_DATA); // print_r($send_reuslt); // exit; // $send_reuslt = array("responseCode" => '9191', "msg" => uniqid()); $status_sql = "update kakao_biztalk_recipient set status = 2 , send_date = now() , code = '".$send_reuslt['responseCode']."' , msg = '".$send_reuslt['msg']."' where cd_recipient = '".$recipient_col['cd_recipient']."' and status = '0' "; mysql_query($status_sql); // // print_r($send_reuslt); // exit; unset($SMS_DATA); } //발송완료로 변경 $standby_sql = "update kakao_biztalk set status = 3 where cd_talk = '".$col['cd_talk']."' "; mysql_query($standby_sql); // exit; } }