Asterisk agi variables pass to php

how can i pass the agi variables to php?

example
pass agi=caller id to a php code.

thanks in advance

the wiki !

voip-info.org/wiki-Asterisk+AGI+php

ive already done that.

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

<?php $stdin = fopen('php://stdin', 'r'); $stdout = fopen('php://stdout', 'w'); $stdlog = fopen('my_agi.log', 'w'); while (!feof($stdin)) { $temp = fgets($stdin); $temp = str_replace("\n","",$temp); $s = explode(":",$temp); $agivar[$s[0]] = trim($s[1]); if (($temp == "") || ($temp == "\n")) { break; } } $caller=$agivar[agi_calleridname]; fwrite(STDOUT, "$caller"); ?>

[/code]

OUTPUT

RX >> 0ource

its not working… by the way im using ,iax, asterisk running in ubuntu 6.10.
pls be patient w/ me im a noob in asterisk :unamused:

anyone who can help me solve this problem :cry:
is there something wrong with my php code?
i really really need help im stuck.

fixed i forgot to open i/o channel.
thanks anyway :astonished:

What do you mean by i/o channel. Can you please show me the php script by now.

  1. Open input and output channels
    Next, you should use fopen() to create all your needed handles. I know different versions of php have varying features to deal with stdio streams but fopen() will work with most new and old versions making your scripts more portable and you don’t have to fidget with the php.ini file. besides, fopen() does not pose any inconvenience for use with * agi, so use it.

$stdin = fopen('php://stdin', 'r'); $stdout = fopen('php://stdout', 'w'); $stdlog = fopen('my_agi.log', 'w');

voip-info.org/wiki/view/Asterisk+AGI+php

silly me i skipped that step hehe :laughing:

Please explain all the detailed steps…
i am unable to get the callerid

try this:
voip-info.org/wiki-Asterisk+AGI+php

thanks i was able to achieve after reading.