You are here

function facebook_album_admin_form_submit in Facebook Album 7.3

Same name and namespace in other branches
  1. 7 facebook_album.admin.inc \facebook_album_admin_form_submit()
  2. 7.2 facebook_album.admin.inc \facebook_album_admin_form_submit()

Implements hook_admin()

Attempts to fetch an application access token from facebook based off of the app ID and app secret specified in the form

1 string reference to 'facebook_album_admin_form_submit'
facebook_album_admin_form in ./facebook_album.admin.inc
Implements hook_admin().

File

./facebook_album.admin.inc, line 55
facebook_album.admin.inc Facebook Album administration pages.

Code

function facebook_album_admin_form_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  variable_set('facebook_album_access_token', NULL);
  $app_id = $form_state['values']['facebook_album_appID'];
  $app_secret = $form_state['values']['facebook_album_appSecret'];
  if (empty($app_secret) || strlen(trim($app_secret)) < 1) {
    $app_secret = variable_get('facebook_album_appSecret');
    unset($form_state['values']['facebook_album_appSecret']);
  }
  $token = _facebook_album_fetch_application_access_token($app_id, $app_secret);
  if (isset($token['error'])) {
    $message = _facebook_album_translate_api_error($token['error']['code'], $token['error']['message']);
    if ($message == 'Invalid Client ID') {
      form_set_error('facebook_album_appID', $message);
    }
    elseif ($token['error']['code'] == 1) {
      form_set_error('facebook_album_appID', $message);
      form_set_error('facebook_album_appSecret');
    }
    else {
      drupal_set_message(check_plain($message), 'error');
    }
  }
  else {
    variable_set('facebook_album_access_token', $token['access_token']);
  }
}