<div dir="ltr">Please find the attached PHP file<br><br><div class="gmail_quote">On Fri, Oct 3, 2008 at 11:29 PM, Michael Collins <span dir="ltr">&lt;<a href="mailto:mcollins@fcnetwork.com">mcollins@fcnetwork.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">










<div lang="EN-US" link="blue" vlink="blue">

<div>

<p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy">You need to handle each response from the
server, no? Can you post your PHP code here?</span></font></p>

<p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy">In Perl I would do something like this.</span></font></p>

<p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy"><br>
</span></font><font size="2" color="navy" face="Courier New"><span style="font-size:10.0pt;color:navy"># $data contains
CHANNEL_ANSWER event stuff</span></font></p>

<p><font size="2" color="navy" face="Courier New"><span style="font-size:10.0pt;color:navy">if ( $data =~
m/Answered-State: (\w+)/m ) {</span></font></p>

<p><font size="2" color="navy" face="Courier New"><span style="font-size:10.0pt;color:navy">&nbsp; my $state = $1;</span></font></p>

<p><font size="2" color="navy" face="Courier New"><span style="font-size:10.0pt;color:navy">&nbsp; print "Channel
state is $state\n";</span></font></p>

<p><font size="2" color="navy" face="Courier New"><span style="font-size:10.0pt;color:navy">&nbsp; if ( $state eq 'answered'
) {</span></font></p>

<p><font size="2" color="navy" face="Courier New"><span style="font-size:10.0pt;color:navy">&nbsp;&nbsp;&nbsp; # do whatever
U need to do on an answer event</span></font></p>

<p><font size="2" color="navy" face="Courier New"><span style="font-size:10.0pt;color:navy">&nbsp; }</span></font></p>

<p><font size="2" color="navy" face="Courier New"><span style="font-size:10.0pt;color:navy">}</span></font></p>

<p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy">&nbsp;</span></font></p>

<p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy">-MC</span></font></p>

<p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy">P.S. – I tested the regex with the
data file you posted and it worked perfectly for me in Perl 5. Since PHP is a
Perl derivative I think you should be able to do this without too much hassle
as long as you have a means of reading the socket data reliably and acting
accordingly.</span></font></p>

<p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy">&nbsp;</span></font></p>

<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">

<div>

<div align="center" style="text-align:center"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">

<hr size="2" width="100%" align="center">

</span></font></div>

<p><b><font size="2" face="Tahoma"><span style="font-size:10.0pt;font-family:Tahoma;font-weight:bold">From:</span></font></b><font size="2" face="Tahoma"><span style="font-size:10.0pt;font-family:Tahoma">
<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>
[mailto:<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>] <b><span style="font-weight:bold">On Behalf Of </span></b>Gopal krishnan<br>
<b><span style="font-weight:bold">Sent:</span></b> Friday, October 03, 2008
10:33 AM<div class="Ih2E3d"><br>
<b><span style="font-weight:bold">To:</span></b> <a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a><br>
</div><b><span style="font-weight:bold">Subject:</span></b> Re: [Freeswitch-users]
get channel status</span></font></p>

</div><div><div></div><div class="Wj3C7c">

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">&nbsp;</span></font></p>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">Hi,</span></font></p>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">&nbsp;</span></font></p>

</div>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">&nbsp;&nbsp;I am trying to get thru a PHP file but i get the output as
,</span></font></p>

</div>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">&nbsp;</span></font></p>

</div>

<div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">authMessage
sent, got response:</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">Content-Type:
command/reply Reply-Text: +OK accepted</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">command
is api originate sofia/default/<a href="mailto:9894929942@172.20.176.254" target="_blank">9894929942@172.20.176.254</a>
1001 command sent, got response:</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">Content-Type:
api/response Content-Length: 41</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">command
sent, got response:</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">+OK
c5df1f4c-02ae-4353-b709-ad791ca332a1</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">command
is bgapi originate sofia/default/<a href="mailto:1001@172.20.176.254" target="_blank">1001@172.20.176.254</a>
1001 &amp;park command sent, got response:</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">Content-Type:
command/reply Reply-Text: +OK Job-UUID: d5270c3d-872e-46b6-b556-74bc373b1fe4
Job-UUID: d5270c3d-872e-46b6-b556-74bc373b1fe4</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">command
is event channel_answer command sent, got response:</span></font></b></span></p>

</div>

<div>

<p><span><b><font size="3" face="Times New Roman"><span style="font-size:12.0pt;font-weight:bold">Content-Type:
command/reply Reply-Text: +OK event listener enabled plain&nbsp;</span></font></b></span></p>

</div>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">&nbsp;</span></font></p>

</div>

<div>

<p><span><font size="3" color="red" face="Times New Roman"><span style="font-size:12.0pt;color:red">So I need to
run the event channel_answer as a&nbsp;separate&nbsp;program with
autorefreshing?</span></font></span></p>

</div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">&nbsp;</span></font></p>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">On Fri, Oct 3, 2008 at 10:49 PM, Brian West &lt;<a href="mailto:brian@freeswitch.org" target="_blank">brian@freeswitch.org</a>&gt; wrote:</span></font></p>


<div style="word-wrap:break-word">

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">Yes if you parse the event using something like perl, ruby, php and get
it...</span></font></p>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">&nbsp;</span></font></p>

</div>

<div>

<p><font size="3" color="#888888" face="Times New Roman"><span style="font-size:12.0pt;color:#888888">/b</span></font></p>

</div>

<div>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">&nbsp;</span></font></p>

<div>

<div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">On Oct 3, 2008, at 12:10 PM, Gopal krishnan wrote:</span></font></p>

</div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><br>
<br>
</span></font></p>

<p style="margin-bottom:12.0pt"><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black"><span style="text-align:auto;word-spacing:0px">File attached</span></span></font></p>


<div>

<p><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black">On Fri, Oct 3, 2008
at 10:36 PM, Gopal krishnan&nbsp;&lt;<a href="mailto:saigop@gmail.com" target="_blank">saigop@gmail.com</a>&gt;&nbsp;wrote:</span></font></p>

<div>

<p><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black">Hi,</span></font></p>

<div>

<p><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black">&nbsp;</span></font></p>

</div>

<div>

<p><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black">&nbsp;&nbsp;By giving
event channel_answer in telnet console I get lots of variables, I am attaching
it as a text file with this email. And my query is for example If I want to
pickup only Answer state from that output, &nbsp;is that possible?</span></font></p>

<div>

<p><font size="1" color="black" face="Helvetica"><span style="font-size:9.0pt;font-family:Helvetica;color:black">&nbsp;</span></font></p>

</div>

</div>

</div>

</div>

</div>

<p><font size="3" face="Times New Roman"><span style="font-size:12.0pt"></span>&nbsp;</font></p>

</div>

</div>

</div>

<p style="margin-bottom:12.0pt"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><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></span></font></p>

</div>

<p style="margin-bottom:12.0pt"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><br>
<br clear="all">
<br>
-- <br>
Thank you &nbsp;with regards,<br>
Gopal,</span></font></p>

</div>

</div>

</div></div></div>

</div>

</div>


<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><br clear="all"><br>-- <br>Thank you &nbsp;with regards,<br>Gopal,<br><br>
</div>