function drupagram_account_oauth_validate in Drupagram 6
Same name and namespace in other branches
- 7 drupagram.pages.inc \drupagram_account_oauth_validate()
If OAuth is enabled, intercept submission of 'Add Account' form on user/%/edit/drupagram page and redirect to Instagram for auth.
1 string reference to 'drupagram_account_oauth_validate'
- drupagram_account_form in ./
drupagram.pages.inc - Form to add a Instagram account
File
- ./
drupagram.pages.inc, line 196 - Provieds drupagram forms.
Code
function drupagram_account_oauth_validate(&$form, &$form_state) {
module_load_include('lib.php', 'oauth_common');
module_load_include('lib.php', 'drupagram');
$callback_uri = url('instagram/oauth', array(
'absolute' => TRUE,
));
$client_id = variable_get('drupagram_client_id', '');
$client_secret = variable_get('drupagram_client_secret', '');
if ($client_id == '' || $client_secret == '') {
form_set_error('', t('Please configure your Instagram client id and secret.'));
}
$drupagram = new InstagramOAuth($client_id, $client_secret);
$_SESSION['drupagram_oauth']['account'] = user_load($form['uid']['#value']);
$_SESSION['drupagram_oauth']['destination'] = $_GET['q'];
drupal_goto($drupagram
->get_authorize_url($callback_uri));
}