title: Find Facebook global profile ID from app_scoped_user_id
body: <p>This has been asked plenty of times on Stack Overflow, but all answers explain how to convert a Facebook profile ID to an <code>app_scoped_user_id</code>. I am asking for exactly the opposite:</p>
  
  <ul>
  <li>I have an <code>app_scoped_user_id</code>, provided by Facebook Graph API.</li>
  <li>I want the global profile ID, so I can output the link to the user's Facebook page.</li>
  </ul>
  
  <p>Here is the flow of my PHP application:</p>
  
  <ul>
  <li>A <a href="https://developers.facebook.com/docs/php/FacebookRequest/4.0.0" rel="nofollow">Facebook Request</a> is made to <code>/me</code>, returning a <a href="https://developers.facebook.com/docs/php/FacebookResponse/4.0.0" rel="nofollow">Facebook Response</a></li>
  <li>On the Response, I call getGraphObject() to return a <a href="https://developers.facebook.com/docs/php/GraphObject#user-instance-methods" rel="nofollow">Facebook Graph Object</a>.</li>
  </ul>
  
  <p>When authenticating with my own Facebook account, this is the contents of the Graph Object:</p>
  
  <pre><code>array (size=11)
    'id' =&gt; string '1117686364915316' (length=16)
    'email' =&gt; string 'greg.bowler@g105b.com' (length=21)
    'first_name' =&gt; string 'Greg' (length=4)
    'gender' =&gt; string 'male' (length=4)
    'last_name' =&gt; string 'Bowler' (length=6)
    'link' =&gt; string 'https://www.facebook.com/app_scoped_user_id/1117686364915316/' (length=61)
    'locale' =&gt; string 'en_GB' (length=5)
    'name' =&gt; string 'Greg Bowler' (length=11)
    'timezone' =&gt; int 1
    'updated_time' =&gt; string '2015-06-23T10:12:53+0000' (length=24)
    'verified' =&gt; boolean true
  </code></pre>
  
  <p>From this, I need to be able to provide a link to my Facebook account. This can easily be done by knowing the Facebook account's ID, buy going to <a href="http://facebook.com/profile.php?id=XXXXX" rel="nofollow">http://facebook.com/profile.php?id=XXXXX</a>, which will even redirect to the correct page if you have named your account.</p>
  
  <p>However, the ID that is specified in the Graph Object response is <strong>not</strong> my global Facebook ID; it is a <code>app_scoped_user_id</code>, specific to the application I'm authenticating with.</p>
  
  <p><strong>How can I convert the <code>app_scoped_user_id</code> to the global ID of my account?</strong></p>
  
  <p>For example, the website <a href="http://findmyfacebookpageid.com/" rel="nofollow">http://findmyfacebookpageid.com/</a> does this, although its source code is closed.</p>
  
  <p>I can provide my <code>app_scoped_user_id</code> to the service here: <a href="http://findmyfacebookpageid.com/get.php?url=https://www.facebook.com/app_scoped_user_id/1117686364915316" rel="nofollow">http://findmyfacebookpageid.com/get.php?url=https://www.facebook.com/app_scoped_user_id/1117686364915316</a></p>
  
  <p>and it returns: </p>
  
  <pre><code>{
  facebook_id: "100000218905189"
  }
  </code></pre>
  
  <p>To prove this question is answerable, I can use the returned <code>facebook_id</code> value to access my actual Facebook page by visiting <a href="http://facebook.com/profile.php?id=100000218905189" rel="nofollow">http://facebook.com/profile.php?id=100000218905189</a></p>