Issue Sending SMS using phpagi through SMS Gateway

My system using php agi received the caller is as below

$callerid = $agi->get_variable(‘CALLERID(num)’);

I tried to send SMS using the phone number received through $callerid.

It is not working, may this be due to encoding issue?

SMS application works fine if I pass a phone number manually in pho script, but fails using the $callerid received from during call using phi agi in asterisk

Please advice.

Thanks in advance.
Shanti

Based on your code I will assume you are using PHPAGI class, so try this one $cid = $agi->parse_callerid(); this will create an associative array where called id number will be included as one of the array values. use print_r($cid); to retun all keys and value from the array and you will know which is the one holding the caller id number, depending on your phpagi version could be one of this :

$cid[‘name’];

$cid[username];

When executed from the terminal it works and SMS is sent
But when I call to the system, no sending of SMS happens along with failure to paly prompts.

CLI shows the following error

[Jan 24 12:10:33] ERROR[26642][C-00000008]: utils.c:1321 ast_carefulwrite: write() returned error: Broken pipe

Please help

It seems yourAGI scipt is not reading all the responses from Asterisk. This thread might be helpful for you
http://forums.asterisk.org/viewtopic.php?f=1&t=86912

Thank you for your kind reply.