ขอ code การส่ง sms ด้วยครับ อยากได้ตัวอย่าง code การส่ง sms ส่ง sms แบบ วนลูป อ่านค่าจากตารางนะครับ
code php ที่ใช้ส่ง SMS ครับ
//##########################
//
// Program: SMS Sender
// By: Suparat Leelathum
// web site:http://www.expert2you.com/
// last modified: 16 Mar 2003
//
//#########################
function tis2utf8($tis) {
for( $i=0 ; $i< strlen($tis) ; $i++ ){
$s = substr($tis, $i, 1);
$val = ord($s);
if( $val < 0x80 ){
$utf8 .= $s;
} elseif ( ( 0xA1 <= $val and $val <= 0xDA ) or ( 0xDF <= $val and $val <= 0xFB ) ){
$unicode = 0x0E00 + $val - 0xA0;
$utf8 .= chr( 0xE0 | ($unicode >> 12) );
$utf8 .= chr( 0x80 | (($unicode >> 6) & 0x3F) );
$utf8 .= chr( 0x80 | ($unicode & 0x3F) );
}
}
return $utf8;
}
//****************************************************************\
//Config:
$username="xxxxxx"; //icq username
$passw="xxxxxxx"; //icq password
$country = "66"; //country code such as Thailand is 66
$area_code="x"; //area code such as 01, please put 1
$phonenumber="xxxxxxx"; //phonenumber
$message = tis2utf8("ทดสอบการส่งภาษาไทย"); //sms message
//****************************************************************
// Do Login
$dat = "karma_success_url=".urlencode("http://web.icq.com/sms/inbox/?")."&karma_fail_url=".urlencode("/login/login_page?karma_product_css=icq2go&karma_success_url=http%3A%2F%2Fweb%2Eicq%2Ecom%2Fsms%2Finbox%2F%3F&karma_forget=&karma_service=")."&karma_service="."&karma_user_login=".urlencode($username)."&karma_user_passwd=".urlencode($passw)."&karma_remember=1"."&submit=".urlencode(" Log in ");
$contentlength= strlen($dat);
$htmlreply="";
$hdr = "POSThttp://web.icq.com/newlogin/1,,,00.htmlHTTP/1.0\r\n";
$hdr .= "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*\r\n";
$hdr .= "Referer: http://web.icq.com/login/login_page/?karma_product_css=icq2go&karma_forget=&karma_service=&karma_success_url=http%3A%2F%2Fweb%2Eicq%2Ecom%2Fsms%2Finbox%2F%3F\r\n";
$hdr .= "Accept-Language: th\r\n";
$hdr .= "Content-Type: application/x-www-form-urlencoded\r\n";
$hdr .= "Accept-Encoding: gzip, deflate\r\n";
$hdr .= "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)\r\n";
$hdr .= "Host: web.icq.com\r\n";
$hdr .= "Content-Length: ".$contentlength."\r\n";
$hdr .= "Proxy-Connection: Keep-Alive\r\n";
$hdr .= "Pragma: no-cache\r\n";
$hdr .= "\r\n";
$post = $hdr.$dat."\r\n";
$remote = fsockopen("web.icq.com", 80, &$errno, &$errstr, 30);
fputs($remote, $post);
while (!feof($remote)) {
$htmlreply.=fgets($remote,120);
}
fclose($remote);
// Uncomment for debug1 ,check return after login:
echo "
HTML Reply
".$htmlreply ;
//****************************************************************
// Get cookies from ICQ
$temp_cookie = explode("karma2_data=",$htmlreply);
//เชคค่า cookie echo "Bobby $l == $temp_cookie[1]";
$temp_cookiea = explode(";",$temp_cookie[1]);
//เป็นคำสั่งตัดข้อความตัดท่อนแรกแบ่งครึ่ง ตัดอีกทีตัดหลังจาก cookie ออก เลยเหลือแต่ cookie ครับผม
//เชคค่า cookie echo "$temp_cookiea[0]";
//$splited = split("\n",nl2br($htmlreply));
//$cookies = $splited[12];
$cookies = $temp_cookiea[0];
$cookiesplit = split(";",$cookies);
$s_data = $cookiesplit[0];
$cookies = str_replace("Set-Cookie: karma2_data=","",$s_data);
// Uncomment for debug 2, check cookie:
echo "
Cookie
".$cookies;
//****************************************************************
// Send SMS Message
$contentprefix = "+".$country;
$charcount = (160-strlen($message));
$dat = "";
$dat .= "-----------------------------7d12442eab5\r\n";
$dat .= "Content-Disposition: form-data; name=\"country\"\r\n";
$dat .= "\r\n";
$dat .= $country."\r\n";
$dat .= "-----------------------------7d12442eab5\r\n";
$dat .= "Content-Disposition: form-data; name=\"prefix\"\r\n";
$dat .= "\r\n";
$dat .= $contentprefix."\r\n";
$dat .= "-----------------------------7d12442eab5\r\n";
$dat .= "Content-Disposition: form-data; name=\"carrier\"\r\n";
$dat .= "\r\n";
$dat .= $area_code."\r\n";
$dat .= "-----------------------------7d12442eab5\r\n";
$dat .= "Content-Disposition: form-data; name=\"tophone\"\r\n";
$dat .= "\r\n";
$dat .= $phonenumber."\r\n";
$dat .= "-----------------------------7d12442eab5\r\n";
$dat .= "Content-Disposition: form-data; name=\"uSend\"\r\n";
$dat .= "\r\n";
$dat .= "1\r\n";
$dat .= "-----------------------------7d12442eab5\r\n";
$dat .= "Content-Disposition: form-data; name=\"charcount\"\r\n";
$dat .= "\r\n";
$dat .= $charcount."\r\n";
$dat .= "-----------------------------7d12442eab5\r\n";
$dat .= "Content-Disposition: form-data; name=\"msg\"\r\n";
$dat .= "\r\n";
$dat .= $message."\r\n";
$dat .= "-----------------------------7d12442eab5--\r\n";
$contentlength= strlen($dat);
$htmlreply="";
$hdr = "POSThttp://web.icq.com/sms/send_msg_tx/1,,,00.htmlHTTP/1.0 \r\n";
$hdr .= "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */* \r\n";
$hdr .= "Referer: ".urlencode("http://web.icq.com/sms/inbox/?")." \r\n";
$hdr .= "Accept-Language: th \r\n";
$hdr .= "Content-Type: multipart/form-data; charset=UTF-8; boundary=---------------------------7d12442eab5\r\n";
$hdr .= "Accept-Encoding: gzip, deflate \r\n";
$hdr .= "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) \r\n";
$hdr .= "Host: web.icq.com \r\n";
$hdr .= "Content-Length: ".$contentlength." \r\n";
$hdr .= "Proxy-Connection: Keep-Alive \r\n";
$hdr .= "Pragma: no-cache \r\n";
$hdr .= "Cookie: karma2_uin=".$username."; karma2_data=".$cookies."; karma2_sdata=".urlencode("CTR(64-1):cw==")."; karma2_rem=".urlencode("CTR(64-1):dA==")." \r\n\r\n";
$post = $hdr.$dat;
$remote = fsockopen("web.icq.com", 80, &$errno, &$errstr, 30);
fputs($remote, $post);
while (!feof($remote)) {
$htmlreply.=fgets($remote,120);
}
fclose($remote);
//Uncomment for debug 3, check the status after send the message to the mobile phone:
echo "
After Send
".$htmlreply;
//****************************************************************
if (strpos($htmlreply,"sms//error")==0)
{
Echo "
SMS Send!";
}
else {
echo "
Error sending SMS!";
}
?>
Date :
2009-09-08 11:24:09
By :
sulove001
ถ้าขอ code โปรแกรม Matlab / GUI จะได้มั๊ยคะ
Date :
2011-02-01 16:53:07
By :
NU_C
Load balance : Server 04