Размер файла: 1.21Kb
<?php
function sms($command,$param=false,$rus_sms=false,$source_phone_no=false)
{
global $napishi_login;
global $napishi_pass;
$mess = '<?xml version="1.0" encoding="utf-8"?><request><user>'.$napishi_login.'</user><pwd>'.$napishi_pass.'</pwd>';
$mess.='<command>'.$command.'</command>';
if($command=='send')
{
$mess.='<product_id>5</product_id><country_code>'.$param[0].'</country_code><area_code>'.$param[1].'</area_code><phone_no>'.$param[2].'</phone_no><message_body>'.$param[3].'</message_body>';
if($rus_sms) $mess.='<rus_sms>1</rus_sms>';
if($source_phone_no) $mess.='<source_phone_no>'.$source_phone_no.'</source_phone_no>';
}
elseif($command=='status')
{
$mess.='<order_id>'.$param[0].'</order_id>';
}
$mess.='</request>';
$request = "POST /extxml.asp HTTP/1.0\r\n";
$request .= "User-Agent: Sitepoint XML-RPC Client 1.0\r\n";
$request .= "Host: www.napishi.ru\r\n";
$request .= "Content-type: text/xml\r\n";
$request .= "Content-length: ".strlen($mess)."\r\n";
$request .= "\r\n";
$request .= $mess."\r\n";
$s = fsockopen("www.napishi.ru", 80, $errno, $errstr, 30);
fputs($s, $request);
$content = '';
while (!feof($s))
{
$content .= fgets($s, 4096);
}
fclose($s);
return $content;
}
?>