Q
Q
qpPeW2017-05-16 20:40:12
PHP
qpPeW, 2017-05-16 20:40:12

How to get USSD response in Asterisk?

Good day, I use the PHPAGI library to work with Asterisk, but I just can’t figure out how to get a response that comes in a couple of seconds, and not immediately.
I have this code that sends a ussd request.

include('phpagi.php');
$manager = new AGI_AsteriskManager();
$manager->connect();
$manager->Command('dongle ussd dongle0 *111#');
$manager->disconnect();

I tried to write the answer to a variable, but only what comes in the answer is saved there.
include('phpagi.php');
$manager = new AGI_AsteriskManager();
$manager->connect();
$result = $manager->Command('dongle ussd dongle0 *111#');
$manager->disconnect();
print_r($result);

In such cases, I get a response.
Array
(
[data] => Privilege: Command
[dongle0] USSD queued for send with id 0x7f5754001a80
[Response] => Follows
)

Well, after 2-3 seconds, the answer I need appears in the console, but I can’t figure out how to get it.
I used to use the phpSerial library, but because it works directly with ports, it doesn’t quite fit, although the functions are exactly what you need. In terms of functions, there is a readPort () function that saves all incoming and outgoing data, I'm looking for something similar in PHPAGI.
I would be grateful to someone who will tell you or poke his nose, maybe I missed something, that's why I can't find a solution, thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2017-05-17
@Zarom

You have [Response] => Follows returned . Try like this:

include('phpagi.php');
$manager = new AGI_AsteriskManager();
$manager->connect();
$manager->Command('dongle ussd dongle0 *111#');
$result = $manager->wait_response();
$manager->disconnect();
print_r($result);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question