Hello, I am trying to send a http POST request to a remote server with a specific port and path with XML data. Communication to the server is available at:
http://example.com:99999/pathname
I've tried doing this with both cURL and fsockopen. I've previosuly done this on a different system with cURL without any problems but I've not had to deal wth the combination of port number and path before and I think this might be causing me the problem.
Below is one of many cURL tries I've done, it returns: Curl error: No URL set!
error_reporting(E_ALL);
ini_set('display_errors', 'On');
$request = '<?xml version="1.0" encoding="UTF-8" ?>XML IN HERE';
$url = "http://example.com:99999/pathname";
$ch = curl_init();
curl_setopt($ch, curlOPT_URL, $url);
curl_setopt($ch, curlOPT_POST, 1);
curl_setopt($ch, curlOPT_POSTFIELDS, urlencode($request));
curl_setopt($ch, curlOPT_HEADER, 1);
curl_setopt($ch, curlOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, curlOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
echo '<br />Curl error: ' . curl_error($ch);
curl_close($ch);
I've also tried separating the port off into the curl_setopt($ch, curlOPT_PORT, $port) with $port set but this returns the same error.
Can anyone point me in the right direction? Any help appreciated.