title: How to fix: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found?
body: <p>I'm helping a NGO with their website (<a href="http://aapot.com.br" rel="nofollow">http://aapot.com.br</a>) and I'm getting an error on a script that fetches photos from a Facebook album.</p>
  
  <p>It was working fine on Localhost but when I moved to the server, it gives an error.</p>
  
  <p>The script is:</p>
  
  <pre><code>&lt;?php
                  $json_link = "http://graph.facebook.com/207640916063623/photos?fields=source";
                  $json = file_get_contents($json_link);
                  $obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);
                  $photo_count = count($obj['data']);
                  for($x=0; $x&lt;$photo_count; $x++){
                  $source = $obj['data'][$x]['source'];
                  $id = $obj['data'][$x]['id'];
                      echo "&lt;li style='width:auto !important;height:100px;'&gt;&lt;a href='#{$id}' data-toggle='modal'&gt;&lt;img src='{$source}' style='width:auto !important;height:150px;' /&gt;&lt;/a&gt;";
                      echo "&lt;/li&gt;";
                  }
              ?&gt;
  </code></pre>
  
  <p>It gets the following error:</p>
  
  <p>Warning: : file_get_contents(<a href="http://graph.facebook.com/207640916063623/photos?fields=source" rel="nofollow">http://graph.facebook.com/207640916063623/photos?fields=source</a>): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/u295274872/public_html/wp-content/themes/aapot/index.php  on line 40.</p>
  
  <p>I've already checked and fopen is enabled. The PHP version is 5.5.</p>
  
  <p>Please, any ideas about how to fix this?</p>
  
  <p>Thanks!</p>