How can I monitor a call record by using asterisk manager?

hello, Guys:
I am trying to use asterisk manager command to monitoring the call between two clients. my manager is connected to asterisk server. but eventually, there is no record under /var/spool/asterisk/monitor and no error comes out from php. here is my code to record the calls:

$asterisk_ip = “192.168.0.88”;
$socket = fsockopen($asterisk_ip,“5038”, $errno, $errstr, $timeout);
fputs($socket, “Action: Login\r\n”);
fputs($socket, “UserName: myasterisk\r\n”);
fputs($socket, “Secret: mycode\r\n\r\n”);
$wrets=fgets($socket,128);
// echo $wrets;
fputs($socket, “Action: Monitor\r\n” );
fputs($socket, “Channel: SIP/$num\r\n” );
fputs($socket, “File: $num\r\n” );
fputs($socket, “Mix: 1\r\n” );
$wrets=fgets($socket,128);
// echo $wrets;
echo “done !!!”;

who knows this problem, please give me a hand.
thank you!

you have to send the monitor command the complete channel name, like SIP/123-a53b - SIP/123 by itself will not work.

based on your code, i’m guessing you don’t have the trailer on the channel num, which is probably the issue.

try appending the full channel name and i’m betting that will work.

Helllo, Friend:
I will try it.

Hello, Friend:
I have tried the suggestion you given me. and i tested again. nothing is under my monitoring dir. the channle is like this: SIP/8811-1ad5.

$asterisk_ip = “192.168.0.88”;
$socket = fsockopen($asterisk_ip,“5038”, $errno, $errstr, $timeout);
fputs($socket, “Action: Login\r\n”);
fputs($socket, “UserName: myasterisk\r\n”);
fputs($socket, “Secret: mycode\r\n\r\n”);
$wrets=fgets($socket,128);
fputs($socket, “Action: Monitor\r\n”);
fputs($socket, “Channel: $channel\r\n”); // SIP/8811-1ad5
fputs($socket, “File: $number\r\n”);
fputs($socket, “Mix: 1\r\n”);
$wrets=fgets($socket,128);
echo $wrets;

the result is : Response: Success.
please give me a further help!

what does the log show you for this failed attempt ? how are you establishing the SIP channel to use each time ?

Hello, Friend:
there is no error to display and response is sucessful. Actually, i use asterisk manager API to monitor the incoiming calls. When the calls are connected and start tallking to each other, I click a link, the link will pass the channel name to a php code, which gets the channle name and use the above php to record the conversition. by the way, I also asterisk manager API to transfer and conduct a call. the two features work fine. do you have any idea ?
thank you very much!