0

I am trying to fetch some data with this code

function file_get_contents_curl($url) {
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_URL, $url);
 $data = curl_exec($ch);
 curl_close($ch);
 return $data;
 }
  $file= file_get_contents_curl('www.website.com/page');

and I get errorno 7

CURLE_COULDNT_CONNECT (7)
Failed to connect() to host or proxy.

I have tried with www.google.com too, but i've got the same error.

I guess that i have to change something on server (linux), but i dont know what.

Thank you.

user3549602
  • 69
  • 1
  • 8

1 Answers1

0

Your question is already answered before. You can checked this question:

How to resolve cURL Error (7): couldn't connect to host? If you can't catch google ,You must checked your firewall.

Community
  • 1
  • 1
reihaneh
  • 7
  • 3
  • I have checked that url in answer, but i don't know how to disable selinux on my hosting server. I haven't mention that my code work on localhost. – user3549602 Jan 23 '16 at 21:38