Run callbacks when user hung up call from IVR
<p>I used this PHP library <a href="http://marcelog.github.io/articles/pagi_tutorial_create_voip_telephony_application_for_asterisk_with_agi_and_php.html" rel="nofollow">PAGI</a> to build an IVR application with Asterisk.
For every call I need to do some cleanups and write something to the database. So I need some callback/handler after user hung up the call.</p>

<p>ASAIK, this library provides some way to detect hangup from user:</p>

<pre><code>pcntl_signal(SIGHUP, $signalHandler);
</code></pre>

<p>However this is not going to work after I picked up the call by sending command <code>ANSWER</code>. If it is used without <code>ANSWER</code>, the above callback does work after the call is hung up!</p>

<p>So I would like to know what is the workaround for my situation?</p>