ก๊วนซอฟท์แวร์ </softganz> SoftGang (Gang Software)

Web &amp; Software Developer Gang.

PHP : Send SMS by smsgateway.com

by Little Bear @3 เม.ย. 55 16:57 ( IP : 122...68 ) | Tags : PHP
<?php
function smsnotify($mobile_no,$msg,$sender) {
    $user_id    = "gatewayusername";
    $passwd = "gatewaypassword";
    $host       = "api.smsgateway.com";<br />
    $port       = "80";<br />
    $path   = "/api_sms.jsp";

    $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)) {
            $buffer=fgets($fp,128);
        }
        fclose($fp);
    }
}
$phonno='00000000';
$msg='This is a SMS message';
smsnotify($phonno,$msg,"SenderName");
?>

ปล. ยังไม่ได้ทดสอบนะจ๊ะ

ที่มา www.thaihosttalk.com