title: PHP file_get_contents/curl - getting different result than browser
body: <p>I'm trying to get content of this page: <a href="http://www.nytimes.com/2014/01/26/us/politics/rand-pauls-mixed-inheritance.html?hp&amp;_r=0" rel="nofollow noreferrer">http://www.nytimes.com/2014/01/26/us/politics/rand-pauls-mixed-inheritance.html?hp&amp;_r=0</a></p>
  
  <p>I tried <code>file_get_contents</code> and <code>curl</code> solution but all gives me a Login page of NYTimes and I have no idea why.</p>
  
  <p>Tried these <a href="https://stackoverflow.com/questions/20553346/file-get-contents-curl-getting-unexpected-page">file_get_contents()/curl getting unexpected page</a>, <a href="https://stackoverflow.com/questions/2548451/php-file-get-contents-behaves-differently-to-browser">PHP file_get_contents() behaves differently to browser</a>, <a href="https://stackoverflow.com/questions/18362048/file-get-content-get-the-wrong-web">file_get_content get the wrong web</a></p>
  
  <p>Is there any solution? Thanks</p>
  
  <p>EDIT:</p>
  
  <pre><code>    //this is the curl code I use
      $cookieJar = dirname(__FILE__) . '/cookie.txt';
      curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieJar);
      curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieJar);
      curl_setopt($ch, CURLOPT_URL, $link);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026     Firefox/3.6.12');
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
      $data    = curl_exec($ch);
      curl_close($ch);
  </code></pre>