AGI - Channel hangup

Hi,

A little problem here, I made a small PHP script for hangup of a active channel. But the problem is - to hangup a channel you have to know the whole channel info:

“SIP/101-0000000e

How can i just tell AGI to hangup on a channel of a SIP number 101 - without knowing the bold number or letters (preferably with an wild card)?!?

The part of the script:

      $socket = fsockopen($asterisk_ip,"5038", $errno, $errstr, $timeout);
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: $user\r\n");
            fputs($socket, "Secret: $pass\r\n\r\n");
            fputs($socket, "Action: Hangup\r\n" );
            fputs($socket, "Channel: SIP/101\r\n" );
	fputs($socket, "Async: yes\r\n\r\n" );
	fputs($Socket, "Events: on\r\n");
	fputs($Socket, "Action: Logoff\r\n\r\n");

You may want to try and use the phpagi.php library vs. doing this by hand.

As far as wildcards, I don’t believe there are any. You will probably have to connect to the manager (from within your script) and get a list of all channels and then find the one you are looking for so you can control it.