ตอนนี้ผมกำลังทำ php + sms gateway เพื่อ sms แจ้งเตือนนัดหมาย ผู้ป่วย
ผมได้ api ของ sms gateway มาเป็นแบบนี้
<?
# Function Send SMS
function send_sms($mobile_no,$msg,$sender) {
$user_id = "xxxxx";
$passwd = "xxxxx";
$host = "smsgateway.packetlove.com";
$port = "80";
$path = "/api_sms.jsp";
// Message
$data="user_id=$user_id&passwd=$passwd&sender=$sender&mobile_no=$mobile_no&msg=$msg";
$fp=@fsockopen($host,80);
if ( $fp)
{
fputs($fp,"POST $path HTTP/1.1\r\n");
fputs($fp,"Host: $host\r\n");
fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp,"Content-length: ".strlen($data)."\r\n");
fputs($fp,"Connection: close\r\n\r\n");
fputs($fp,$data);
while(!feof($fp)) {
// Return Message From Gateway
$buffer=fgets($fp,128);
echo "$buffer\n";
}
fclose($fp);
}
}
// Test Send SMS Function
send_sms("0868011680","Test Send SMS","0888888888")
?>