Implement callback AGI (PHP)
Calling back via agi is a simple technique and can be used as long as you know it. |
[Capiin] Exten = & gt; 1234/016066666, 1, Wait, 1 Exten = & gt; 1234/016066666, 2, AGI, callback. php Exten = & gt; 1234/016066666, 3, Hangup |
|
Callback. php <? P h p Ob_implicit_flush (true ); Set_time_limit (0 ); $ Err = fopen ("php: // stderr", "w "); $ In = fopen ("php: // stdin", "r "); While (! Feof ($ in )){ $ Temp = str_replace ("\ n", "", fgets ($ in, 4096 )); $ S = split (":", $ temp ); $ Agi [str_replace ("agi _", "", $ s [0])] = trim ($ s [1]); If ($ temp = "") | ($ temp = "\ n ")){ Break; } } $ Cf = fopen ("/home/kapejod/pbx/var/spool/asterisk/outgoing/cb ". $ agi ["callerid"], "w +"); fputs ($ cf, "Channel: CAPI /". $ agi ["extension"]. ":". $ agi ["callerid"]. "\ n "); Fputs ($ cf, "Context: capidialtone \ n "); Fputs ($ cf, "Extension: s \ n "); Fputs ($ cf, "SetVar: CALLERIDNUM =". $ agi ["extension"]. "\ n "); Fputs ($ cf, "MaxRetries: 2 \ n "); Fputs ($ cf, "RetryTime: 10 \ n "); Fclose ($ cf ); Fclose ($ in ); Fclose ($ err ); ? > |