Skip to content

Instantly share code, notes, and snippets.

@caefer
Created September 27, 2011 19:53
Show Gist options
  • Select an option

  • Save caefer/1246045 to your computer and use it in GitHub Desktop.

Select an option

Save caefer/1246045 to your computer and use it in GitHub Desktop.
<?php
function swap_access_token_for_page($access_token, $page_id)
{
$accounts = file_get_contents('https://graph.facebook.com/me/accounts?access_token='.$access_token);
$accounts = json_decode($accounts, true);
if (isset($accounts['data'])) {
foreach ($accounts['data'] as $account) {
if ($page_id == $account['id']) {
return $account['access_token'];
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment