[главная] | [каталоги]
0
создан: 2020-12-23 21:12:28
пользователь: cloud раздел: программирование
[984]
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="<request><PageIndex>1</PageIndex><ReadCount>5</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>";
$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 . '<br /> text: ' . $cat->Content . '<hr>';
}
if($i_sms < 1){
echo 'сообщений нет';
}