Put port in curl

Hi everyone.
I want to send xml data using curl, and I need to put in my script port 8080.

Here is my script, but it doesn’t work, I’m thinking maybe server don’t allow me to send post to this port?


$post_url = "http://SOMEIP:8080/";
$xml_string = '<?xml version="1.0" encoding="UTF-8"?>';


$ch = curl_init($post_url);

curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_PORT , 8080);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "xmldata=".$xml_string);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);


$data = curl_exec($ch);
// to get information on the curl resultset
$info = curl_getinfo($ch);
print_r($data);
if(curl_errno($ch)){
    print curl_error($ch);
}

curl_close($ch);

You might want to check with your hosting provider, they may be blocking the port on outbound at the firewall.

Do you get any error messages?

Yes, when I’m using port, it’s telling me that it couldn’t connect to the host. But when I’m removing the port, it’s successfully sends datas.

edgarzakaryan

This, drop them a support ticket, code looks fine to me