0

If I put in my php file:

echo file_get_contents("http://www.example.com/myPage.php");

If I run this script on example.com, the page eventually times out. If I run the same script on a different server, it loads correctly immediately. I checked and allow_url_fopen is 'On' in phpinfo(). Any ideas what this could be? Thanks in advance.

Tom
  • 1,215
  • 3
  • 19
  • 30
  • Check to make sure that the system can correctly resolve to it's self. Try this from the command line: `curl http://www.example.com/myPage.php` – Mike Nov 10 '14 at 20:18

2 Answers2

0

Use this class

for getting things DOM from a URL

Like

$html = file_get_html("http://example.com");
echo $html;
Zenel Shabani
  • 95
  • 1
  • 1
  • 10
  • That class also uses file_get_contents() so it runs into the same problem. Thanks though. – Tom Nov 10 '14 at 20:58
0

Inspect the webpage with chrome/firebug in the network tab. see what headers you are sending.

Make a new file_get_contents with the same headers.

See here how to send headers along with file_get_contents

This will be like actually opening the website and thus should work just fine.

Community
  • 1
  • 1
Zenel Shabani
  • 290
  • 2
  • 11