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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.