title: file_get_contents sporadically returns empty string when trying to read webpage
body: <p>I am attempting to load a webpage with file_get_contents(), and am running into problems.</p>
  
  <p>Basically, my web app will use the youtube data api to search for videos based on a user's query, and then read each video's youtube page to find information not provided by the api. I use file_get_contents() to read the youtube pages and then load the text into a DOM parser. Most of the time, this works like a charm. However, on occasion, I'll get warnings saying that  file_get_contents() returned an empty string (not for all videos, only for some of them). I know that the url I am providing is correct, because I echo a link to that url and it works as expected. I'll refresh the page, reopen my browser, switch to a different browser, etc. but nothing will work. Then, I'll leave the thing for an hour or two, come back to it, and it will magically work again!</p>
  
  <p>Here is a snippet of my code:</p>
  
  <pre><code>function processNext($int) {
      // this function processes the next $int videos from the youtube data api response ($xmlDoc)
      global $xmlDoc;
      $begin = count($_SESSION["results"]) - $_SESSION["start"] + 1;
          /* $_SESSION["results"] is the array of already-processed videos
             $_SESSION["start"] and $_SESSION["end"] are the indexes of the first and last videos in the $xmlDoc
          */
      $end = count($_SESSION["results"]) - $_SESSION["start"] + $int;
  
      for ($i = $begin; $i &lt;= $end; $i++) {
          $video = $xmlDoc-&gt;entry[$i];
          $doc = new DOMDocument();
          $doc-&gt;strictErrorChecking = FALSE;
          libxml_use_internal_errors(true);
  
          // this is the line that is causing me problems
          $doc-&gt;loadHTML(file_get_contents(getWatchURL(getVidID($video-&gt;id)))); 
  
          $doc = $doc-&gt;documentElement;
  
                 // then, do some processing on the $doc
  
      }
  }
  </code></pre>
  
  <p>Is it possible that file_get_contents() is timing out? Is cURL a better tool for what I am doing?</p>
  
  <p><strong>UPDATE:</strong> I get the same results with cURL.</p>