Ionisis Posted April 25, 2010 Share Posted April 25, 2010 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 More sharing options...
Ionisis Posted April 26, 2010 Author Share Posted April 26, 2010 Sorry guys, i meant to update this last night. The voip server was legitimately refusing the connection. I had to configure it to allow access fro the web. It was not a php issue. I hope this helps the next guy. Link to comment https://forums.phpfreaks.com/topic/199702-fsockopen-to-curl-for-sip-connection/#findComment-1048842 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.