Вход Регистрация
Файл: _rootinc/epochtasms.inc.php
Строк: 63
<?

class EPOCHTASMS
{
    public 
$url = null;
    public 
$user = null;
    public 
$password = null;
    public 
$error = null;

    public function 
init($url,$user,$password)
    {
        
$this->url=$url;
        
$this->user=$user;
        
$this->password=$password;
    }

    public function 
send($request)
    {
        
$fp = curl_init(); 
        
curl_setopt($fp, CURLOPT_URL, $this->url);
        
curl_setopt($fp, CURL_HTTP_VERSION_1_1, 1);
        
curl_setopt($fp, CURLOPT_POST, 1);
        
curl_setopt($fp, CURLOPT_POSTFIELDS, $request);
        
curl_setopt($fp, CURLOPT_SSL_VERIFYPEER, 0);
        
curl_setopt($fp, CURLOPT_SSL_VERIFYHOST, 0);
        
curl_setopt($fp, CURLOPT_RETURNTRANSFER,1);
        
curl_setopt($fp, CURLOPT_TIMEOUT, 120);

        
$result = curl_exec($fp);

        if (@
curl_errno($fp)) {
            
$this->error = "cURL Error ".@curl_errno($fp).": ".@curl_error($fp);
            return 
false;
        }

        
curl_close($fp);  

        return 
$result;
    }

    public function 
sendSMS($mobile, $sender, $smsid, $smsmsg)
    {
        
$req = "XML=<SMS>
<operations>
<operation>SEND</operation>
</operations>
<authentification>
<username>"
.$this->user."</username>
<password>"
.$this->password."</password>
<userapp>rootpanel</userapp>
</authentification>
<message>
<sender>
$sender</sender>
<text>
$smsmsg</text>
</message>
<numbers>
<number messageID="
$smsid">$mobile</number>
</numbers>
</SMS>"
;
        
$result = $this->send($req);
        
$result = xml2array($result);

        if (
$result[RESPONSE]) {
            if (
$result[RESPONSE][0][status] > 0) {
                return 
$result[RESPONSE][0][credits];
            } else {
                
$errors["-1"] = "AUTH_FAILED: Неправильный логин и/или пароль";
                
$errors["-2"] = "XML_ERROR: Неправильный формат XML";
                
$errors["-3"] = "NOT_ENOUGH_CREDITS: Недостаточно кредитов на аккаунте пользователя";
                
$errors["-4"] = "NO_RECIPIENTS: Нет верных номеров получателей";

                
$errorcode = $result[RESPONSE][0][status];

                
$this->error = "sendSMS: Code ".$errorcode."; ".$errors["$errorcode"];
            }
        } else {
            
$this->error = "sendSMS: no result or cant parse result";
            return 
false;
        }
    }

    public function 
getSMSStatus($id)
    {
        
$req = "XML=<SMS>
<operations>
<operation>GETSTATUS</operation>
</operations>
<authentification>
<username>"
.$this->user."</username>
<password>"
.$this->password."</password>
</authentification>
<statistics>
<messageid>
$id</messageid>
</statistics></SMS>"
;
        
$result = $this->send($req);

        
$result = toarray($result,"deliveryreport",1);

        if (
$result[message][1][attributes][status]) {$i=1;}
        else {
$i=0;}

        if (
$result[message][$i][attributes][id] == $id) {
            
$res[date] = $result[message][$i][attributes][donedate];
            
$res[status] = $result[message][$i][attributes][status];

            return 
$res;
        } else {
            
$this->error = "getSMSStatus: no result or cant parse result";
            return 
false;
        }
    }
}
?>
Онлайн: 1
Реклама