Ok, first off, i run my own voip servers, and wanted to integrate a "click to call" on my company's website. I've seen several examples using fsockopen with php, but i keep getting "connection refused" errors. I tried converting the code to use cURL, but i guess that i do not understand enough about fsockopen and the SIP protocol to properly transpose it to cURL.
One of the files had something like this:
$extension="100" ; //where 9999 is the extension you would like to call
$socket = fsockopen("server.ip","5060", $errno, $errstr, 60);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: xxxx\r\n");
fputs($socket, "Secret: xxxx\r\n\r\n");
$wrets=fgets($socket,128);
echo $wrets;
fputs($socket, "Action: Originate\r\n" );
fputs($socket, "Channel: SIP/$extension\r\n" );
fputs($socket, "Exten: $extension\r\n" );
fputs($socket, "Context: outbound-dialing\r\n" );
fputs($socket, "Priority: 1\r\n" );
fputs($socket, "Async: yes\r\n\r\n" );
$wrets=fgets($socket,128);
echo $wrets;
echo $errstr;
?>
and that didn't work. I even tried using ini_set('user_agent','Mozilla Firefox'); just in case my httpd.conf was blocking it (which it SHOULD have nothing to do with this, since we're going to port 5060), and, as expected, that made no difference.
I tried using the fields above as curl headers, and to convert the approach to curl, and used the curl_setopt to set the port option to 5060, but it's not working. In my php.ini i have allow_url_fopen = On.
Thanks.