You are here

function fb_stream_admin_code_to_token in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 6.3 fb_stream.admin.inc \fb_stream_admin_code_to_token()
1 call to fb_stream_admin_code_to_token()
fb_stream_admin_settings in ./fb_stream.admin.inc
Form callback for general settings.

File

./fb_stream.admin.inc, line 248

Code

function fb_stream_admin_code_to_token($code, $app_id, $redirect_uri) {
  $fb_app = fb_get_app(array(
    'id' => $app_id,
  ));
  $path = url("https://graph.facebook.com/oauth/access_token", array(
    'query' => array(
      'client_id' => $app_id,
      'client_secret' => $fb_app->secret,
      'code' => $code,
      'redirect_uri' => $redirect_uri,
    ),
  ));
  $http = drupal_http_request($path);
  if ($http->code == 200 && isset($http->data)) {
    $data = array();
    parse_str($http->data, $data);
    return $data['access_token'];
  }
}