1

I'm running the following code

<?php 
    echo file_get_contents('http://instagram.com/p/bivXzqRhDt');
?>

And it is causing the client browser (chrome) to perform an infinite auto-refresh to the same page, while not displaying any content. When changing the URL the code works, but I still see no sense on why would a file_get_contents refresh the current page, unless he has some sort of meta refresh (which he doesn't).

What can cause such an infinite refresh in the client side after file_get_contents / curl ?

Clue #1: When I'm looking at the network debug tab, I'm seeing the refresh is called with __a=1. Clue #2: When I'm not echoing the contents it also doesn't refresh.

1 Answers1

0

There is probably some JavaScript code that try to redirect because you display whole instagram page from your own domain, curl won`t help here.

Try to test it by disabling JavaScript in Your Browser. How to disable javascript in chrome developer tools

This should stop infinite refreshing, but you will not see Instagram page content without JavaScript.

I think That it will be very difficult to obtain such behavior. You could try to use iframe but that probably will not work too.

Community
  • 1
  • 1
adam187
  • 3,193
  • 21
  • 15
  • I disabled the JS and the page really didn't refresh, and like you suspected no content was loaded. Any way to identify and disable the JS refresh code? – user2627153 Jul 28 '13 at 12:40
  • From what i see instagram page will not work wihout JavaScript. You could try to analize Javascript`s on the page deeply and finde the code that causes this redirects and try to bypass it. But in My opinion this will probably not be posible. Instagram use XHR requests to download additional data and from what i remember browsers don`t support this requests on other domains by default. – adam187 Aug 01 '13 at 21:00
  • Maybe you could use some headless browser such as http://phantomjs.org and use it to render instagram page content with javascript, this sould probably work. – adam187 Aug 01 '13 at 21:05
  • This should be helpfull too [Execute PhantomJS from PHP](http://michielve.blogspot.com/2013/04/phantomjs-cookie.html) – adam187 Aug 01 '13 at 21:09