Keyur Padalia
Keyur Padalia

Reputation: 1158

Curl not returning data

Hi there i am using following code to get url data but getting nothing

$url = "http://www.amazon.co.uk/dp/B002P44QH2";
$ch = curl_init();echo $url;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$page = curl_exec($ch);
print_r(curl_getinfo($ch));
curl_close($ch);
return $page;

When i do print_r(curl_getinfo($ch)) it returns the following output:

    Array
(
    [url] => http://www.amazon.co.uk/dp/B002P44QH2
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0
    [namelookup_time] => 0.10347
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => 0
    [upload_content_length] => 0
    [starttransfer_time] => 0
    [redirect_time] => 0
)

When i do this in terminal it gives me following error

curl -I http://www.amazon.co.uk/dp/B002P44QH2

Error:

curl: (7) Failed to connect to 178.236.5.39: Network is unreachable

Please Help

Upvotes: 1

Views: 2792

Answers (1)

Sandeep Manne
Sandeep Manne

Reputation: 6092

Is it a shared hosting server, if yes then some shared hosting server wont allow curl requests - check this answer for more info https://stackoverflow.com/a/9953646/308251

Upvotes: 1

Related Questions