You are here

function fb_admin_get_app_token in Drupal for Facebook 7.4

Gets app token from facebook.

2 calls to fb_admin_get_app_token()
fb_admin_application_edit_form_validate in ./fb.admin.inc
Form validation.
_fb_admin_parse_textfield in ./fb.admin.inc
This unlikely helper function speeds copy and paste from facebook. Allows user to put both id and secret in one textfield.

File

./fb.admin.inc, line 930

Code

function fb_admin_get_app_token($fba, $secret) {
  $path = "https://graph.facebook.com/oauth/access_token?client_id=" . $fba . "&client_secret=" . $secret . "&grant_type=client_credentials";
  $http = drupal_http_request($path);
  if ($http->code == 200 && isset($http->data)) {
    $parse = explode('=', $http->data);
    $token = $parse[1];
    return $token;
  }
  else {
    drupal_set_message(t('Failed to get application token. %detail.', array(
      '%detail' => $http->error,
    )), 'error');
  }
}