📜 ⬆️ ⬇️

Rip out sms from GOIP for PHP

Yes, the Asterisk in this article is only indirectly - the method (and script) is intended for further integration into it, depending on the tasks. But there was no more successful hub.

If you missed - specify, correct. Thank!

So, we have GOIP - GSM gateway. There is an SMS server developed by the manufacturer, but I didn’t want to allocate resources for vds for a simple task, and it was designed (it makes sense) to work with several gateways and a good volume. If we have one or two gateways, and we want to see the SMS “insofar - because” - this path may well make sense.
')
In the webmord of the gateway, sms-ki are available in the section “Tools” => “SMS in box”. Yes, yes, this question is not for me - for the Chinese :)
The gateway stores 5 sms per channel.
From there we will tear them out, a PHP script. I will try to comment on what is happening in the source.

<?php /*  SMS  GOIP whoim, whoim@mail.ru */ $goip_addr = "http://goip_external_ip:7454/"; # (    )  goip. ,     , , 7454 => local_goip_addr:80 $goip_user = "admin"; $goip_password = "goip-password"; #     goip- $context = stream_context_create(array( 'http' => array( 'header' => "Authorization: Basic " . base64_encode("$goip_user:$goip_password") ) )); #   - html $data = file_get_contents($goip_addr."/default/en_US/tools.html?type=sms_inbox", false, $context); #    ,  $data = str_replace('\"', '"', $data); //fix #  sms  js-  html,  =  sim preg_match_all("|sms= \[(.*?)\]|is", $data, $sms_dump_arr); $sms = array(); #  -  " sim",   5 -,     .    csv. #      str_getcsv        . foreach($sms_dump_arr[1] as $sim_key => $sim_val) foreach(str_getcsv($sim_val) as $sms_key => $sms_val) { $sms[$sim_key][$sms_key] = explode(',', $sms_val, 3); # 0,1,2  , ,  . $sms[$sim_key][$sms_key][] = md5($sms_val); # 3    ,    sms-   } #  print_r($sms); ?> 


This script is a stub. What to do with the data is your business. I will check the hash if it is still in the database, and if not, put a nameplate in mysql. This is necessary, because the page always contains the last 5 sms, that is - the data in the absence of changes will still be, watch for duplicates.

Good luck!

Source: https://habr.com/ru/post/258561/


All Articles