Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php Curl live server not working

Tags:

php

curl

I test the script on my localhost and it working perfectly. I tried on my the live server and it didn't work.

<?php
   $uploadfile=dirname(__FILE__)."/xml_request/cat.xml"; 
   $ch = curl_init("http://remote.xxxxxxxxxx.com.au:8090/Options.API");   
   curl_setopt($ch, CURLOPT_POSTFIELDS,
               array('Request'=>"@$uploadfile",
                     'clientKey'=>'xxxxxxxxxxxxxxxxxxx'));
   curl_setopt($ch, CURLOPT_PORT, '8090');
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   $postResult = curl_exec($ch);

   $response = curl_getinfo($ch);
   echo "<pre>";
   print_r($response);
   echo "</pre>";

   curl_close($ch);
   echo "<pre>";
   print_r($postResult);
   //file_put_contents(dirname(__FILE__).'/xml_record/live.xml', $postResult);

?>

Localhost I print_r the curl_getinfo($ch).

Array
(
    [url] => http://remote.xxxxxxxx.com.au:8090/Options.API
    [content_type] => text/html; charset=utf-8
    [http_code] => 200
    [header_size] => 246
    [request_size] => 215
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 2.278
    [namelookup_time] => 0
    [connect_time] => 0.344
    [pretransfer_time] => 0.344
    [download_content_length] => 9376
    [upload_content_length] => 759
    [starttransfer_time] => 0.734
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [redirect_url] => 
)

Live test I print_r the curl_getinfo($ch).

 Array
    (
        [url] => http://remote.xxxxxxxxxxx.com.au:8090/Options.API
        [content_type] => 
        [http_code] => 0
        [header_size] => 0
        [request_size] => 0
        [filetime] => -1
        [ssl_verify_result] => 0
        [redirect_count] => 0
        [total_time] => 0.012024
        [namelookup_time] => 0.011809
        [connect_time] => 0
        [pretransfer_time] => 0
        [download_content_length] => -1
        [upload_content_length] => -1
        [starttransfer_time] => 0
        [redirect_time] => 0
    )

Not sure if the port of the url is the problem. I try to search to solve the problem but no luck.

like image 789
Jows Avatar asked Feb 11 '26 16:02

Jows


1 Answers

From Comments:

Your webhost is probably blocking outbound traffic on port 8090. Many webhosts block uncommon ports for added security. The only way to get this resolved is to contact your webhost and ask them to unblock the port so that you can connect on it.

like image 184
Bad Wolf Avatar answered Feb 17 '26 02:02

Bad Wolf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!