<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Arial; font-size: 12pt; color: #000000'><div><span>Hi.</span></div><div><span><br></span></div><div>From the php manual:&nbsp;<span style="font-family: verdana, arial, helvetica, sans-serif; font-size: 14px; background-color: rgb(245, 245, 255);">Reading ends when&nbsp;</span><em style="font-weight: bold; font-family: verdana, arial, helvetica, sans-serif; font-size: 14px; background-color: rgb(245, 245, 255);"><code class="parameter" style="font-family: Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace;">length</code></em><span style="font-family: verdana, arial, helvetica, sans-serif; font-size: 14px; background-color: rgb(245, 245, 255);">&nbsp;- 1 bytes have been read, or a newline&nbsp;</span></div><span><div><span><br></span></div>Link: http://www.php.net/fgets</span><div><br></div><div><span>This should work:</span></div><div><span><i><br></i></span></div><div><span><i>while(!feof($in)) {</i></span></div><div><i>&nbsp; &nbsp; $text = fgets($in);<br>&nbsp; &nbsp; file_put_contents('/usr/local/freeswitch/scripts/socketlog.txt' ,$text, FILE_APPEND);</i></div><div><span><i>}<br></i><br><span name="x"></span>Denis<span name="x"></span><br></span><br><hr id="zwchr"><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;"><b>Da: </b>"Michael Collins" &lt;msc@freeswitch.org&gt;<br><b>A: </b>"FreeSWITCH Users Help" &lt;freeswitch-users@lists.freeswitch.org&gt;<br><b>Inviato: </b>Mercoledì, 10 luglio 2013 19:05:01<br><b>Oggetto: </b>Re: [Freeswitch-users] PHP ESL &amp; Event Socket Outbound<br><br><div dir="ltr"><div>I'll have to defer to those who know PHP better than I, but my first question would be: does fgets read all data off the input buffer or does it read one line at a time?<br><br></div>-MC<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Jul 10, 2013 at 3: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>&nbsp; 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'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("php://stdin", "r");<br><br>// Connect<br>

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

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

echo "execute-app-arg: /usr/local/freeswitch/sounds/en/us/callie/ivr/8000/ivr-welcome_to_freeswitch.wav\n\n";<br><br>// Wait<br>sleep(5);<br><br>// Hangup<br>echo "sendmsg\n";<br>echo "call-command: hangup\n\n";<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" target="_blank">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" target="_blank">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><br clear="all"><br>-- <br>Michael S Collins<br>Twitter: @mercutioviz<br><a href="http://www.FreeSWITCH.org" target="_blank">http://www.FreeSWITCH.org</a><br><a href="http://www.ClueCon.com" target="_blank">http://www.ClueCon.com</a><br>
<a href="http://www.OSTAG.org" target="_blank">http://www.OSTAG.org</a><br><br>
</div>
<br>_________________________________________________________________________<br>Professional FreeSWITCH Consulting Services:<br>consulting@freeswitch.org<br>http://www.freeswitchsolutions.com<br><br>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>http://www.cudatel.com<br><br>Official FreeSWITCH Sites<br>http://www.freeswitch.org<br>http://wiki.freeswitch.org<br>http://www.cluecon.com<br><br>FreeSWITCH-users mailing list<br>FreeSWITCH-users@lists.freeswitch.org<br>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>http://www.freeswitch.org<br></blockquote><br></div></div></body></html>