ช่วยแปลงโค้ด php เป็น vb2008 ทีครับ
เป็นโค้ดเกี่ยวกับการส่ง ค่า ไปยังผู้ให้บริการ SMS Service นะครับ
<?php
$gcuser = 'xxx'; $gcpass = 'xxx';
/** ส่ง SMS ไปยังหมายเลขที่ต้องการ $phoneNO = หมายเลขปลายทาง เช่น 0896695520 $text = ข้อความที่ต้องการส่ง $sender = ชื่อผู้ส่ง (ตัวเลข+ตัวอักษรภาษาอังกฤษไม่เกิน 10 ตัว ห้ามเว้นวรรค) จะ return 'OK' ถ้าสำเร็จ หรือ 'ERROR:รายละเอียด' ถ้าไม่สำเร็จ */ function send_sms($phoneNO, $text, $sender, $wapurl = '') { global $gcuser,$gcpass; $url = 'http://www.3gsms.in.th/smsapi.php'; $data = array( 'gcuser' => $gcuser, 'gcpass' => $gcpass, 'sender' => $sender, 'phoneNO' => $phoneNO, 'text' => $text, 'wapurl' => $wapurl ); $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL, $url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 4s curl_setopt($ch, CURLOPT_POST, 1); // set POST method curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // add POST fields curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);// don't verfiy SSL host curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);// don't verify SSL peer $result = curl_exec($ch); // run the whole process curl_close($ch); $result = trim($result); $resultNode = simplexml_load_string($result); $status = $resultNode->STATUS; $detail = $resultNode->DETAIL; if($status == 'OK') { return $status; } else { return $status . ":" . $detail; } } /** ตรวจสอบ credit คงเหลือ ถ้าผิดพลาดจะ return "ERROR:" ตามด้วยรหัส error เช่น ERROR:101 ถ้าใช้ได้จะ return "OK:" ตามด้วย credit คงเหลือ ตามด้วย ":" ตามด้วยวันหมดอายุในรูปแบบ yyyy-MM-dd */ function check_sms_credit() { global $gcuser,$gcpass; $url = 'http://www.3gsms.in.th/smscheck.php'; $data = array( 'gcuser' => $gcuser, 'gcpass' => $gcpass, 'cmd' => "check" ); $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL, $url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 4s curl_setopt($ch, CURLOPT_POST, 1); // set POST method curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // add POST fields curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);// don't verfiy SSL host curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);// don't verify SSL peer $result = curl_exec($ch); // run the whole process if(curl_error($ch)) { die('curl_error: ' . curl_error($ch)); } curl_close($ch); $result = trim($result); $resultNode = simplexml_load_string($result); $status = $resultNode->STATUS; $detail = $resultNode->DETAIL; if($status == 'OK') { $credit = $resultNode->DETAIL->CREDIT; $expire = $resultNode->DETAIL->EXPIRE; return $status . ":" . $credit . ":" . $expire; } else { return $status . ":" . $detail; }
return $result; } //echo htmlspecialchars(send_sms('0860506900',iconv('tis620', 'UTF-8', 'ทดสอบการส่ง SMS'), '3GSMS')) . "<br />"; //echo htmlspecialchars(send_sms('0860506900',iconv('tis620', 'UTF-8', 'ทดสอบการส่ง wappush'), '3GSMS', 'mobile.watta.co.th/gc/wp.php')) . "<br />"; //echo check_sms_credit(); ?>
|