Jump to content

fsockopen to cURL for SIP connection


Ionisis

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/199702-fsockopen-to-curl-for-sip-connection/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.