Answer the question
In order to leave comments, you need to log in
Routing in Asterisk via tele2 API, where to dig?
The essence of the problem lies in the incorrect routing of outgoing calls to cell numbers using operator prefixes. Many subscribers began to switch to other operators while keeping the number, which led to the problem of determining the operator, saving on communications and calculating the communication budget for organizations.
An API was found from tele2 mnp.tele2.ru/gateway.php?XXXXXXXXX, which accurately determines whether the number belongs to the operator, I really need the help of Aster specialists, maybe I can write some script to work with the API, can you tell me which way to dig?
Answer the question
In order to leave comments, you need to log in
In order not to request each time, it is worth keeping your database of numbers, then the algorithm is something like this:
1. We query the database by number, if they are not older than N days (ODBC or MYSQL)
2. If there is no data in the database (or they are old), then make a request to the site (CURL)
3. If the data is received from the site, parse the string, enter the data into the database with the request time
4. If there is no data, we work out the standard call plan or try to determine by prefixes
Additionally, you can make an external script that will periodically small portions to update the data in the table.
Don't do bullshit. take it in the original source. The database is updated monthly in the first days.
www.rossvyaz.ru/activity/num_resurs/registerNum
You use the search. Everything has been done for a long time.
asteriskforum.ru/viewtopic.php?t=6716&start=25
curl mnp.tele2.ru/gateway.php?9814603300 | sed 's/ /-/g' | sed 's/:/ /g' | awk '{print $6}' | sed -r 's/}.+//
'
Original source?
Here there is a manual request, the number is the operator.
www.zniis.ru/bdpn/check
There is also information on how to access the database. Getting it is not difficult.
And then you already do the "daily" unloading, process for your telephony system as you like/need.
For some reason, lately it has often been buggy. I had to use an alternative option with a megaphone.
mnp.sh:
#!/bin/bash
curl -s -X POST " moscow.shop.megafon.ru/get_ajax_page.php?action=ge... " |sed -e :a -e 's/<[^ >]*>//g;/;//ba' |iconv -c -f cp1251 -t utf8 |sed 's/\"/\n/g' |awk '{if($0 ~ /tele2/) print "Tele2"; if($0 ~ /MTS/) print "MTS"; if($0 ~ /Beeline/) print "Beeline"; if($0 ~ /MegaFon/) print "Megafon"; }'
Just in case, I'll write as use (alas, not everyone knows):
./mnp.sh 79111111111
And in the dialplan something like this (salt and pepper to taste):
...
same => n(L_check_mnp),NoOP(${ARG1} "
same => n,Set(operator_${ARG1}=${SHELL(/my_scripts/mnp.sh 7${ARG1:1:10})})
...
same => n,NoOP(Operator is ${operator_ ${EXTEN}})
same => n(L_choice),GotoIf($[${operator_${EXTEN}} = Mts]?dial_to_mts,${EXTEN},1)
same => n,GotoIf($[${ operator_${EXTEN}} = Other]?dial_to_other_channels,${EXTEN},1)
same => n,GotoIf($[Other${operator_${EXTEN}} = Other]?dial_to_other_channels,${EXTEN},1)
same => n,Set(GLOBAL(D_N_for_h1)=${EXTEN})
same => n,Set(GLOBAL(F_N_for_h1)=${CALLERID(num)})
same => n,GotoIf($[${operator_$ {EXTEN}} = Megafon]?dial_to_megafon,${EXTEN},1)
same => n,HangUp()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question