[главная] | [каталоги]

создан: 2020-12-23 21:12:28
пользователь: cloud раздел: программирование
[просмотров|394]
192.168.8.1 sms read + php
$curl = curl_init();
$url = "http://192.168.8.1/api/webserver/SesTokInfo";
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$content = curl_exec($curl);
$xml = new simpleXMLElement($content);

$sess_id = $xml->SesInfo;
$tokInfo= $xml->TokInfo;
curl_close($curl);

$data="151001";

$curl2 = curl_init('http://192.168.8.1/api/sms/sms-list/');// A compléter

$headers = array(
'Cookie:'. $sess_id,
'__RequestVerificationToken:'. $tokInfo,
'Content-Type: application/x-www-form-urlencoded; charset=UTF-8',
);

curl_setopt($curl2, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl2, CURLOPT_POST, true);
curl_setopt($curl2, CURLOPT_POSTFIELDS,$data);
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, true);

$content = curl_exec($curl2);
curl_close($curl2);
$xml = new simpleXMLElement($content);

$i_sms = 0;

foreach ($xml->Messages->Message as $cat) {
$i_sms++;
if($cat->Smstat == '1'){
$smstat = '[read]';
} else {
$smstat = '[no read]';
}
echo $smstat . ' tel: ' . $cat->Phone . ' text: ' . $cat->Content . '';
}

if($i_sms < 1){
echo 'сообщений нет';
}

fizord.ru © 2021
site by cl0oud