Facebook扩展令牌仅适用于一页,如何休息

I have the following code to generate an extended token. No SDK involved. I get the initial temporary token with the Graph API Explorer.

  $api_action = 'me/accounts';
  $url = 'https://graph.facebook.com/' . $this->facebook_api_version . '/' . $api_action;
  $url_with_token = $url . '?access_token=' . $this->facebook_temporary_access_token . '';
  $account = json_decode(file_get_contents($url_with_token));
  $page_access_token = $account->data[0]->access_token;

  // Get extended access token
  $access_token = '';
  $url = 'https://graph.facebook.com/oauth/access_token?client_id=' . $this->facebook_app_id . '&client_secret=' . $this->facebook_app_secret . '&grant_type=fb_exchange_token&fb_exchange_token=' . $page_access_token;
  $result = file_get_contents($url);
  $result = str_replace('access_token=', '', $result);
  $result = explode('&expires', $result);
  $facebook_extended_access_token = $result[0];
  echo '<pre>'; print_r($facebook_extended_access_token); echo '</pre>';
  return $facebook_extended_access_token;

This application has three pages associated with it. The problem is this only generates an extended token for the Page A. I've verified using the Facebook Toke Debugger.

https://developers.facebook.com/tools/debug/access_token?q=

How can I generate an extended token for Facebook Page B and C and not just A.

Credit to CBroe's comment.

I found that the first API call in my code was actually returning temporary access tokens for all of my pages, but I was set up to only return the first. $account->data[1]->access_token and $account->data[2]->access_token hold B and C. Here is my final code for those that find it useful.

  $api_action = 'me/accounts';
  $url = 'https://graph.facebook.com/' . $this->facebook_api_version . '/' . $api_action;
  $url_with_token = $url . '?access_token=' . $this->facebook_temporary_access_token . '';
  $account = json_decode(file_get_contents($url_with_token));

  // Loop through each store
  foreach ($account->data as $data) {
    $page_access_token = $data->access_token;
    // Get extended access token
    $access_token = '';
    $url = 'https://graph.facebook.com/oauth/access_token?client_id=' . $this->facebook_app_id . '&client_secret=' . $this->facebook_app_secret . '&grant_type=fb_exchange_token&fb_exchange_token=' . $page_access_token;
    $result = file_get_contents($url);
    $result = str_replace('access_token=', '', $result);
    $result = explode('&expires', $result);
    $facebook_extended_access_token = $result[0];
    echo '<pre>'; print_r($facebook_extended_access_token); echo '</pre>';
  }