keywords: ip pbx voip gateway gsm gateway

×

Notice

The forum is in read only mode.
× Questions about VS-GW2120/GW1600/GW1202 and WGW1002G GSM Series VoIP Gateway

send ussd problem AGI

9 years 11 months ago #9693 by mostafafayyaz
Hi .
i want to send ussd from AGi on windows with wampserver.

firstly i downloaded PHP-agi , then i changed exec_goto to exec_goto_new.
afther that, i created user and IP in asterisk API.
then i used this code to connect
include("phpagi-asmanager.php"); 
$agi=new AGI_AsteriskManager; 
$vst_host='192.168.1.118'; 
$vst_user='admin'; #Corresponding to your GSM gateway API settings 
$vst_pwd='admin'; #Corresponding to your GSM gateway API settings 
$vst_port=5038; #Corresponding to your GSM gateway API settings 
$agi_status=$agi->connect($vst_host.":".$vst_port,$vst_user,$vst_pwd); 
if($agi_status) 
 { 
 echo $msg="Connection is OK";
 exit(0);
 } 
else {
echo "connection failed";
}

the result of code is "connection is OK" , this show that i connected to asterisk.
after that i used $agi->Command("gsm send ussd 1 *444# ");
but this code can not return the result. the ussd code can show the result in Asterisk_CLI
please help me
thanks
9 years 11 months ago #9695 by tim.june
Hi,

Why not use our web gui to send ussd code?
[attach]325[/attach]


Your code is only for sending USSD, and you did nothing to handle the feedback of USSD code, how could it be possible to show you the result on your php code? If you need to return the result on your php, you need to monitor the related EVENTs through AMI connection. About howto, pls google AMI interface.

Email: This email address is being protected from spambots. You need JavaScript enabled to view it.
Skype: tim.jjune
Attachments:
9 years 11 months ago #9696 by mostafafayyaz
i want to send ussd and give back returns from PHP
because i need it to check the credits automatically
9 years 11 months ago #9697 by rick.zhu
Hi,

This is Rick,please refer to below code test it,if still have some issues,please contact me directly,my contact info be shown as bwlow:
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.
Skype: rick.zhu3

PHP code:

#!/usr/bin/php
<?php
// include("/var/lib/asterisk/agi-bin/phpagi.php");
// include("/var/lib/asterisk/agi-bin/agifunction.php");
// include("phpagi-asmanager.php");
// $agi=new AGI_AsteriskManager;

$vst_host='172.16.8.46';
$vst_user='admin'; #Corresponding to your GSM gateway API settings
$vst_pwd='admin'; #Corresponding to your GSM gateway API settings
$vst_port=5038; #Corresponding to your GSM gateway API settings

$socket = socket_create(AF_INET, SOCK_STREAM, 0);
if ($socket < 0)
{
echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";
}
else
{
echo "OK.\n";
}
echo "Try to connect '$vst_host' port '$vst_port'...\n";
$result = socket_connect($socket, $vst_host, $vst_port);
if ($result < 0)
{
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
}
else
{
echo "Connect success\n";
}
$LoginMessage = "action:Login\r\nusername:admin\r\nsecret:admin\r\n\r\n";
echo $LoginMessage;
if(!socket_write($socket,$LoginMessage,strlen($LoginMessage)))
{
echo "send the logine message error\n";
return;
}
$SendUSSD = "action:Command\r\nCommand:gsm send ussd 1 13632919026 test\r\n\r\n";
echo $SendUSSD;
if(!socket_write($socket,$SendUSSD,strlen($SendUSSD)))
{
echo "send the USSD message error\n";
return;
}
while($out=socket_read($socket,1024))
{
echo $out;
}
?>
Time to create page: 0.037 seconds
Powered by Kunena Forum