# PHPAGI in Asterisk-1.6.2.0\[Solved\]

**URL:** <https://community.asterisk.org/t/phpagi-in-asterisk-1-6-2-0-solved/30274>\
**Category:** Asterisk Support\
**Created:** [January 18, 2010, 9:54pm UTC](https://community.asterisk.org/t/phpagi-in-asterisk-1-6-2-0-solved/30274 "2010-01-18T21:54:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![navaismo](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/navaismo/32/2481_2.png) [@navaismo](https://community.asterisk.org/u/navaismo)\
**Post date:** [January 18, 2010, 9:54pm UTC](https://community.asterisk.org/t/phpagi-in-asterisk-1-6-2-0-solved/30274/1 "2010-01-18T21:54:34Z")

</div>

I have a agi script running in asterisk 1.4.28 but when upgrade the asterisk to 1.6.2.0 and PHP-5.3.1 the script doesnt work anymore. I try with a simple script but not run:

[code]#!/usr/bin/php -q

\<?php set\_time\_limit(30); require('phpagi/phpagi.php'); error\_reporting(E\_ALL); $agi = new AGI(); $agi-\>answer(); $agi-\>stream\_file('/var/lib/asterisk/sounds/en/tt-monkeys'); $agi-\>hangup(); ?\>[/code]

Output CLI:

` == Using SIP RTP CoS mark 5
    -- Executing [5444@default:1] AGI("SIP/4100-00000043", "getdata.agi") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/getdata.agi
<SIP/4100-00000043>AGI Tx >> agi_request: getdata.agi
<SIP/4100-00000043>AGI Tx >> agi_channel: SIP/4100-00000043
<SIP/4100-00000043>AGI Tx >> agi_language: es
<SIP/4100-00000043>AGI Tx >> agi_type: SIP
<SIP/4100-00000043>AGI Tx >> agi_uniqueid: 1263851318.67
<SIP/4100-00000043>AGI Tx >> agi_version: 1.6.2.1
<SIP/4100-00000043>AGI Tx >> agi_callerid: 4100
<SIP/4100-00000043>AGI Tx >> agi_calleridname: unknown
<SIP/4100-00000043>AGI Tx >> agi_callingpres: 0
<SIP/4100-00000043>AGI Tx >> agi_callingani2: 0
<SIP/4100-00000043>AGI Tx >> agi_callington: 0
<SIP/4100-00000043>AGI Tx >> agi_callingtns: 0
<SIP/4100-00000043>AGI Tx >> agi_dnid: 5444
<SIP/4100-00000043>AGI Tx >> agi_rdnis: unknown
<SIP/4100-00000043>AGI Tx >> agi_context: default
<SIP/4100-00000043>AGI Tx >> agi_extension: 5444
<SIP/4100-00000043>AGI Tx >> agi_priority: 1
<SIP/4100-00000043>AGI Tx >> agi_enhanced: 0.0
<SIP/4100-00000043>AGI Tx >> agi_accountcode: 
<SIP/4100-00000043>AGI Tx >> agi_threadid: -1254409360
<SIP/4100-00000043>AGI Tx >> 
    -- <SIP/4100-00000043>AGI Script getdata.agi completed, returning 0`

But if I try with standar script, it run fine:

[code]#!/usr/bin/php -q

\<? ob\_implicit\_flush(false); set\_time\_limit(6); $stdin = fopen('php://stdin', 'r'); $stdlog = fopen('my\_agi.log', 'w'); $debug = true; /\* Read input from Asterisk and output via $astOutput \*/ function astRead() { global $stdin, $debug, $stdlog; $astOutput = str\_replace("\n", "", fgets($stdin, 4096)); if ($debug) fputs($stdlog, "read: $input\n"); return $astOutput ; } /\* Write AGI command to Asterisk \*/ function astWrite($agiCommand) { global $debug, $stdlog; if ($debug) fputs($stdlog, "write: $agiCommand\n"); echo $agiCommand."\n"; } /\* Handling execution input from Asterisk \*/ $agivar = array(); while (!feof($stdin)) { $temp = fgets($stdin); $temp = str\_replace("\n","",$temp); $s = explode(":",$temp); $agivar[$s[0]] = trim($s[1]); if ($temp == "") { break; } } /\* Operational Code starts here \*/ /\* Playback the demo-congrats.gsm file from the \* directory /var/lib/asterisk/sounds/ \*/ astWrite("STREAM FILE /var/lib/asterisk/sounds/en/tt-monkeys #"); astRead(); /\* Say the number 123456 astWrite("SAY NUMBER 123456 #"); astRead();\*/ /\* Finalization of AGI script and clean-ups \*/ fclose ($stdin); fclose ($stdlog); exit(0); ?\>[/code]

Output CLI:

`-- Executing [5666@default:1] Answer("SIP/4100-00000044", "") in new stack
    -- Executing [5666@default:2] AGI("SIP/4100-00000044", "getdata2.agi") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/getdata2.agi
<SIP/4100-00000044>AGI Tx >> agi_request: getdata2.agi
<SIP/4100-00000044>AGI Tx >> agi_channel: SIP/4100-00000044
<SIP/4100-00000044>AGI Tx >> agi_language: es
<SIP/4100-00000044>AGI Tx >> agi_type: SIP
<SIP/4100-00000044>AGI Tx >> agi_uniqueid: 1263851364.68
<SIP/4100-00000044>AGI Tx >> agi_version: 1.6.2.1
<SIP/4100-00000044>AGI Tx >> agi_callerid: 4100
<SIP/4100-00000044>AGI Tx >> agi_calleridname: unknown
<SIP/4100-00000044>AGI Tx >> agi_callingpres: 0
<SIP/4100-00000044>AGI Tx >> agi_callingani2: 0
<SIP/4100-00000044>AGI Tx >> agi_callington: 0
<SIP/4100-00000044>AGI Tx >> agi_callingtns: 0
<SIP/4100-00000044>AGI Tx >> agi_dnid: 5666
<SIP/4100-00000044>AGI Tx >> agi_rdnis: unknown
<SIP/4100-00000044>AGI Tx >> agi_context: default
<SIP/4100-00000044>AGI Tx >> agi_extension: 5666
<SIP/4100-00000044>AGI Tx >> agi_priority: 2
<SIP/4100-00000044>AGI Tx >> agi_enhanced: 0.0
<SIP/4100-00000044>AGI Tx >> agi_accountcode: 
<SIP/4100-00000044>AGI Tx >> agi_threadid: -1254409360
<SIP/4100-00000044>AGI Tx >> 
<SIP/4100-00000044>AGI Rx << STREAM FILE /var/lib/asterisk/sounds/en/tt-monkeys #
    -- Playing '/var/lib/asterisk/sounds/en/tt-monkeys' (escape_digits=#) (sample_offset 0)
<SIP/4100-00000044>AGI Tx >> 200 result=-1 endpos=38080
    -- <SIP/4100-00000044>AGI Script getdata2.agi completed, returning -1`

So PHPAGI, its dead for asterisk-1.6.2.0 or I miss something.

---

<div class="post-metadata">

**Author:** ![shmaize](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@shmaize](https://community.asterisk.org/u/shmaize)\
**Post date:** [January 18, 2010, 10:58pm UTC](https://community.asterisk.org/t/phpagi-in-asterisk-1-6-2-0-solved/30274/2 "2010-01-18T22:58:00Z")

</div>

Try to run the script manually from the shell.

---

<div class="post-metadata">

**Author:** ![navaismo](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/navaismo/32/2481_2.png) [@navaismo](https://community.asterisk.org/u/navaismo)\
**Post date:** [January 18, 2010, 11:35pm UTC](https://community.asterisk.org/t/phpagi-in-asterisk-1-6-2-0-solved/30274/3 "2010-01-18T23:35:14Z")

</div>

Thank you,

Yes, when run from console it report an incompatibility with PHP 5.3.1 caused by command GOTO, so I replaced the every Goto for goto3 in phpagi.php, and run perfectly.

Thanks Again.
