========== Start of PHP CLI Script ==========
#!/usr/local/bin/php
<?php
$fp = fsockopen("www.sample.com", 80, $errno, $errstr, 30); //對方的IP或FQDN
if (!$fp) {
echo 'Could not open connection.';
} else {
$xmlpacket ='<?XML version="1.0"?>
//接著填入要發出的XML內容
//這部分得依照提供Web Server的廠商給的規格填,例如:
<login_name>帳號</login_name>
<login_pwd>密碼</login_pwd>
<request_type>指令</request_type>
<message>簡訊內容</message>
<phone_no>電話號碼1</phone_no>
<phone_no>電話號碼2</phone_no>
<phone_no>電話號碼3</phone_no>
</smva_request>';
$contentlength = strlen($xmlpacket);
$out = "POST /bin/sms.cgi HTTP/1.0\r\n"; //提供服務的程式
$out .= "Host: www.sample.com\r\n"; //網站hostname
$out .= "Connection: Keep-Alive\r\n";
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Content-length: $contentlength\r\n\r\n";
$out .= "XML=$xmlpacket";
fwrite($fp, $out);
while (!feof($fp)) {
$theOutput .= fgets($fp, 128);
}
fclose($fp);
echo $theOutput."\r\n"; //印出對方傳回的訊息
echo "\r\n";
echo "\r\n";
}
?>
========== End of PHP CLI Script ==========
沒有留言:
張貼留言