You are here

function drupagram_oauth_callback_form_submit in Drupagram 6

Same name and namespace in other branches
  1. 7 drupagram.pages.inc \drupagram_oauth_callback_form_submit()

Handle a Instagram OAuth return request and store the account creds in the DB. Redirects to user/%/edit/drupagram

File

./drupagram.pages.inc, line 287
Provieds drupagram forms.

Code

function drupagram_oauth_callback_form_submit(&$form, &$form_state) {
  $client_id = variable_get('drupagram_client_id', '');
  $client_secret = variable_get('drupagram_client_secret', '');
  $response = $form_state['drupagram_oauth']['response'];
  $drupagram = new InstagramOAuth($client_id, $client_secret, $response['access_token']);
  $drupagram_account = new InstagramUser($response['user']);
  $account = $form_state['drupagram_oauth']['account'];
  drupagram_account_save($drupagram_account, TRUE, $account);
  $form['#programmed'] = FALSE;
  $form_state['redirect'] = url('user/' . $account->uid . '/edit/drupagram');
  drupal_goto('user/' . $account->uid . '/edit/drupagram');
}