title: Getting a facebook name out of a fb id - file_get_contents() not working
body: <p>Background:
  I am making a facebook app where users post messages like in a forum. For that I save the users facebook id to then present their names. I know it is possible to show the name out of a facebook id by using the Graph API, but I can't make it work.</p>
  
  <p>The code I use is the following:</p>
  
  <pre><code>//$fbId is the facebook id to find out the name for
  
  $facebookUrl = "https://graph.facebook.com/".$fbId;
  echo(file_get_contents($facebookUrl));
  $str = file_get_contents($facebookUrl);
  $result = json_decode($str);
  echo($result);
  return $result-&gt;name;
  </code></pre>
  
  <p>I researched and tested this for hours, but I feel like I'm getting nowhere. I got an idea of how it works from:</p>
  
  <p><a href="http://www.phpexpertsforum.com/how-to-get-the-facebook-name-with-user-id-using-php-code-t1852.html" rel="nofollow noreferrer">http://www.phpexpertsforum.com/how-to-get-the-facebook-name-with-user-id-using-php-code-t1852.html</a></p>
  
  <p>Didn't work so I researched further from here:</p>
  
  <p><a href="https://stackoverflow.com/questions/5788937/get-users-name-from-facebook-graph-api">Get user&#39;s name from Facebook Graph API</a></p>
  
  <p>I dowloaded and currently use the Facebook php SDK, but I don't find the way to use it to get anyone's name other than the current user.
  The problem here seems to be the file_get_contents() function that returns a false, meaning that it can't read the file. 
  I checked out the php documentation. Also, by using the php functions fopen() and file().</p>
  
  <pre><code>//echo(pathinfo($facebookUrl, PATHINFO_EXTENSION)); -&gt; Doesn't give any response!
  //echo(file_exists($facebookUrl)); -&gt; No response!
  //fopen() doesn't work
  //file() doesn't work
  //file_get_contents() doesn't work
  //tried adding an access token to the $facebookUrl but it doesn't make any difference
  </code></pre>
  
  <p>Any idea of what could be wrong here? Little guidance would be very helpful. What am I doing wrong? What did I miss?</p>