Problems with phpagi.php

Discussion in 'General' started by capizell, Apr 28, 2010.

  1. capizell

    Joined:
    Feb 8, 2010
    Messages:
    6
    Likes Received:
    0
    Hi. I have some problems with the execution of the function 'get_data' from phpagi.php
    I create a file called 'consulta.php':

    #!/usr/bin/php -cgi -q
    <?php
    {
    // ruta a la libreri?a "PHP-AGI"::
    require '/var/lib/asterisk/agi-bin/phpagi.php';
    $agi = new AGI();
    $myServer = "localhost";
    $myUser = "root";
    $myPass = "1234";
    $myDB = "stock";

    //Conexion a la BD.
    $dbhandle = mysql_connect($myServer, $myUser, $myPass)
    or die("Couldn't connect to SQL Server on $myServer");
    //Seleccionar la BD con la que vamos a trabajar.
    $selected = mysql_select_db($myDB, $dbhandle)
    or die("Couldn't open database $myDB");

    $agi->exec('PlayBack','hello-world');
    $captura = $agi->get_data('beep',4000,4);
    $tabla = $captura['data'];
    $agi->exec('SayDigits',$tabla);

    switch ($tabla)
    {
    case 1:
    $query = "SELECT * FROM Fabricantes";
    break;
    case 2:
    $query = "SELECT * FROM Modelos";
    break;
    case 3:
    $query = "SELECT * FROM Coches";
    break;
    case 4:
    $query = "SELECT * FROM Clientes";
    break;
    case 5:
    $query = "SELECT * FROM Reservas";
    break;
    }

    //Ejecucion de la sentencia y almacenamiento del resultado.
    $result = mysql_query($query);
    //Cerrar la conexion.
    mysql_close($dbhandle);
    }
    ?>

    When I execute the agi, I get in the debug:

    == Using SIP RTP TOS bits 184
    == Using SIP RTP CoS mark 5
    == Using SIP VRTP TOS bits 136
    == Using SIP VRTP CoS mark 6
    -- Executing [*100@from-internal:1] Answer("SIP/100-0000005f", "") in new stack
    -- Executing [*100@from-internal:2] AGI("SIP/100-0000005f", "consulta.php") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/consulta.php
    <SIP/100-0000005f>AGI Tx >> agi_request: consulta.php
    <SIP/100-0000005f>AGI Tx >> agi_channel: SIP/100-0000005f
    <SIP/100-0000005f>AGI Tx >> agi_language: en
    <SIP/100-0000005f>AGI Tx >> agi_type: SIP
    <SIP/100-0000005f>AGI Tx >> agi_uniqueid: 1272453246.95
    <SIP/100-0000005f>AGI Tx >> agi_version: 1.6.2.1
    <SIP/100-0000005f>AGI Tx >> agi_callerid: 100
    <SIP/100-0000005f>AGI Tx >> agi_calleridname: device
    <SIP/100-0000005f>AGI Tx >> agi_callingpres: 0
    <SIP/100-0000005f>AGI Tx >> agi_callingani2: 0
    <SIP/100-0000005f>AGI Tx >> agi_callington: 0
    <SIP/100-0000005f>AGI Tx >> agi_callingtns: 0
    <SIP/100-0000005f>AGI Tx >> agi_dnid: *100
    <SIP/100-0000005f>AGI Tx >> agi_rdnis: unknown
    <SIP/100-0000005f>AGI Tx >> agi_context: from-internal
    <SIP/100-0000005f>AGI Tx >> agi_extension: *100
    <SIP/100-0000005f>AGI Tx >> agi_priority: 2
    <SIP/100-0000005f>AGI Tx >> agi_enhanced: 0.0
    <SIP/100-0000005f>AGI Tx >> agi_accountcode:
    <SIP/100-0000005f>AGI Tx >> agi_threadid: -1219675248
    <SIP/100-0000005f>AGI Tx >>
    <SIP/100-0000005f>AGI Rx <<
    <SIP/100-0000005f>AGI Tx >> 510 Invalid or unknown command
    <SIP/100-0000005f>AGI Rx << EXEC PlayBack hello-world
    -- AGI Script Executing Application: (PlayBack) Options: (hello-world)
    -- <SIP/100-0000005f> Playing 'hello-world.gsm' (language 'en')
    <SIP/100-0000005f>AGI Tx >> 200 result=0
    <SIP/100-0000005f>AGI Rx << GET DATA beep 4000 4
    -- <SIP/100-0000005f> Playing 'beep.gsm' (language 'en')
    <SIP/100-0000005f>AGI Rx << EXEC SayDigits
    -- AGI Script Executing Application: (SayDigits) Options: ()
    <SIP/100-0000005f>AGI Tx >> 200 result=0
    <SIP/100-0000005f>AGI Rx <<
    <SIP/100-0000005f>AGI Tx >> 510 Invalid or unknown command
    -- <SIP/100-0000005f>AGI Script consulta.php completed, returning 0
    -- Executing [*100@from-internal:3] Hangup("SIP/100-0000005f", "") in new stack
    == Spawn extension (from-internal, *100, 3) exited non-zero on 'SIP/100-0000005f'
    -- Executing [h@from-internal:1] Macro("SIP/100-0000005f", "hangupcall") in new stack
    -- Executing [s@macro-hangupcall:1] GotoIf("SIP/100-0000005f", "1?skiprg") in new stack
    -- Goto (macro-hangupcall,s,4)
    -- Executing [s@macro-hangupcall:4] GotoIf("SIP/100-0000005f", "1?skipblkvm") in new stack
    -- Goto (macro-hangupcall,s,7)
    -- Executing [s@macro-hangupcall:7] GotoIf("SIP/100-0000005f", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,9)
    -- Executing [s@macro-hangupcall:9] Hangup("SIP/100-0000005f", "") in new stack
    == Spawn extension (macro-hangupcall, s, 9) exited non-zero on 'SIP/100-0000005f' in macro 'hangupcall'
    == Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/100-0000005f'



    The problem is that the file 'beep' isn't reproduce and doesn't get the number, so the function saynumber always says 0.

    In the file 'phpagi.php' the function is defined:

    function get_data($filename, $timeout=NULL, $max_digits=NULL)
    {
    return $this->evaluate(rtrim("GET DATA $filename $timeout $max_digits"));
    }

    I don't if the problem is in 'consulta.php' or in 'phpagi.php', I can't see any error in the code. :(

    Anyone have the same problem?

    Thanks
     
  2. marcalza

    Joined:
    May 23, 2009
    Messages:
    32
    Likes Received:
    0
    I hope you can help me with this

    I have this code

    $result2 = $agi->get_data('/var/lib/asterisk/sounds/es/enter-conf-call-number',3000,10);
    $agi->exec('SayDigits',$result2);


    When SayDigits is executed, I hear 2 0 0 before I hear the numbers I enter in the get_data

    -- AGI Script Executing Application: (SayDigits) Options: (200|33333|timeout)
    -- <SIP/3000-000000bc> Playing 'digits/2.gsm' (language 'es')
    -- <SIP/3000-000000bc> Playing 'digits/0.gsm' (language 'es')
    -- <SIP/3000-000000bc> Playing 'digits/0.gsm' (language 'es')
    -- <SIP/3000-000000bc> Playing 'digits/3.gsm' (language 'es')
    -- <SIP/3000-000000bc> Playing 'digits/3.gsm' (language 'es')
    -- <SIP/3000-000000bc> Playing 'digits/3.gsm' (language 'es')
    -- <SIP/3000-000000bc> Playing 'digits/3.gsm' (language 'es')
    -- <SIP/3000-000000bc> Playing 'digits/3.gsm' (language 'es')


    How can I do to get only de 33333 and avoid the 200?

    Thanks a lot
     

Share This Page