Файл: _rootinc/bytehand.inc.php
Строк: 36
<?
class BYTEHAND
{
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($script,$requestArray)
{
$fp = curl_init();
curl_setopt($fp, CURLOPT_URL, $this->url.$script."?".http_build_query($requestArray));
curl_setopt($fp, CURL_HTTP_VERSION_1_1, 1);
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);
$result = json_decode($result);
return $result;
}
public function sendSMS($mobile, $sender, $smsmsg)
{
$result = $this->send("send","id=$this->user&key=$this->password&text=$smsmsg&to=$mobile&from=$sender");
if ($result[status] == "0") {
return $result[description];
} else {
$this->error = "sendSMS: Code:".$result[status].", ".$result[description];
return false;
}
}
public function getSMSStatus($id)
{
$result = $this->send("status","id=$this->user&key=$this->password&message=$id");
if ($result[status] == "0") {
$date = $result[updated_at];
$date = @mb_split(".",$date);
$date = $date[0];
$res[date] = $date;
$res[status] = $result[description];
$res[cost] = $result[cost];
return $res;
} else {
$this->error = "getSMSStatus: Code:".$result[status].", ".$result[description];
return false;
}
}
}
?>