Witam wszystkich...
Mam pytanie postanowiłem sobie zrobić bramkę sms wykorzystując do tego nieżytkowany modem, wszystko sprawdziłem na swoim podręcznym raspberry i działa idealnie.
Ale chciałem pójść krok dalej i mam problem mianowicie aby wysłać sms wystarczy pobrac token a potem wysłać sms" Może ktoś z szanownych użytkownik podpowie co jest nie tak...
Pobieranie tokena:
curl "http://192.168.8.1/api/webserver/token"
<?xml version="1.0" encoding="UTF-8"?>
<response>
<token>695328588</token>
</response>
Wysyłąnie sms
curl "http://192.168.8.1/api/sms/send-sms" -H "__RequestVerificationToken: 695328588" --data "<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>xxxxxxxxx</Phone></Phones><Sca></Sca><Content>ala ma kota</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>"
I mój wymęczony skrypt ;)
<?php
error_reporting(E_ALL);
// Argumentem jest URL do skryptu z listingu 2.1
$url = ('http://192.168.8.1/api/webserver/token');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER,0);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
preg_match('#<token>(.+?)</token>#si', $curl_scraped_page, $matches);
$token = ($matches[1]);
echo ($token);
$url = ("http://192.168.8.1/api/sms/send-sms");
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ("-H __RequestVerificationToken: 537556192 --data <?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>xxxxxxxxx</Phone></Phones><Sca></Sca><Content>ala ma kota</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_URL,$url);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
echo ($curl_scraped_page);
?>