function drupagram_oauth_callback_form_submit in Drupagram 7
Same name and namespace in other branches
- 6 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
@TODO Redirect better.
I don't much like the use of drupal_goto() here as it might interfere with other modules trying to piggyback on the form submission, but setting $form['redirect'] was leaving us at the drupagram/oauth URL.
File
- ./
drupagram.pages.inc, line 406 - Drupagram admin page callaback functions.
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']);
// $drupagram_account->set_auth($response);
$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');
// redirect isn't firing - because we're using drupal_submit_form()?
// - so adding drupal_goto() here (but not liking it).
drupal_goto('user/' . $account->uid . '/edit/drupagram');
}