<div dir="ltr"><div><div><div><div><div>Hi,<br></div><div><br>This works for me with PHP and outbound socket.<br><br></div>Dialplan: *** sends connection to IP A.B.C.D port 8084<br><br>&lt;extension name=&quot;test&quot;&gt;<br>
    &lt;condition field=&quot;destination_number&quot; expression=&quot;^\*\*\*$&quot;&gt;<br>        &lt;action application=&quot;socket&quot; data=&quot;A.B.C.D:8084&quot;/&gt;<br>    &lt;/condition&gt;<br>&lt;/extension&gt;<br>
<br></div>xinetd picks up the connection and sends to the script. xinetd config is:<br><br><b>service unlisted<br>{<br>         user                = whoever<br>         disable             = no<br>         type                = UNLISTED<br>
         socket_type         = stream<br>         protocol            = tcp<br>         wait                = no<br>         server              = /home/test/test.php<br>         port                = 8084<br>     server_args         = HOST<br>
}<br><br></b></div>The php script picks it up from there<br><br>#!/usr/bin/php<br>&lt;?php<br>require_once(&#39;ESL.php&#39;);<br><br>$esl = new ESLconnection(0);<br><br>$ans= $esl-&gt;execute(&#39;answer&#39;);<br><br>$subscribe = $esl-&gt;sendRecv(&#39;myevents&#39;);<br>
$subscribe = $esl-&gt;sendRecv(&#39;linger&#39;); # Without this the channel closes before we receive the events<br>$res = $esl-&gt;execute(&#39;sleep&#39;, &#39;1000&#39;);<br><br>$context = $esl-&gt;getInfo()-&gt;getHeader(&#39;Caller-Context&#39;);<br>
$curr_user = $esl-&gt;getInfo()-&gt;getHeader(&#39;variable_sip_from_user&#39;);<br>$curr_host = $esl-&gt;getInfo()-&gt;getHeader(&#39;variable_sip_from_host&#39;);<br><br>///etc etc.<br><br></div>Hope that helps<br><br></div>
Mike<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 10, 2013 at 11:23 AM, Milos Jovanovic <span dir="ltr">&lt;<a href="mailto:development.milos@gmail.com" target="_blank">development.milos@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br><br>I am trying to create PHP application that will be receiving information about each call from freeswitch and send commands to control freeswitch.<br>
<br>I found an example at <a href="https://wiki.freeswitch.org/wiki/PHP_ESL#ivrd" target="_blank">https://wiki.freeswitch.org/wiki/PHP_ESL#ivrd</a>  BUT unfortunately they do not explain how I can retrieve information from freeswitch (so I can do the routing in PHP).<br>

<br>I guess I should use PHP ESL but the documentation is pretty bad so if someone has some working example, I&#39;d appreciate it.<br><br>I tried to read from stdin this way:<br><br><br><i>#!/usr/bin/php -q<br><br>&lt;?php<br>

<br>// set a couple of things so we dont kill the system<br>ob_implicit_flush(true);<br>set_time_limit(30);<br><br>// Open stdin so we can read the data in<br>$in = fopen(&quot;php://stdin&quot;, &quot;r&quot;);<br><br>// Connect<br>

echo &quot;connect\n\n&quot;;<br><br>// READ DATA<br>$text = fgets($in);<br>file_put_contents(&#39;/usr/local/freeswitch/scripts/socketlog.txt&#39; ,$text, FILE_APPEND);<br><br>// Answer<br>echo &quot;sendmsg\n&quot;;<br>

echo &quot;call-command: execute\n&quot;;<br>echo &quot;execute-app-name: answer\n\n&quot;;<br><br>// Play a prompt<br>echo &quot;sendmsg\n&quot;;<br>echo &quot;call-command: execute\n&quot;;<br>echo &quot;execute-app-name: playback\n&quot;;<br>

echo &quot;execute-app-arg: /usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav\n\n&quot;;<br><br>// Wait<br>sleep(5);<br><br>// Hangup<br>echo &quot;sendmsg\n&quot;;<br>echo &quot;call-command: hangup\n\n&quot;;<br>

<br>fclose($in);<br><br>?&gt;</i><br><br><b>Unfortunately, everything I get as a result in my log file is:</b><br><br><i>Event-Name: CHANNEL_DATA</i><br><br>
<br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>