You are here

function feeds_oauth_callback in Feeds OAuth 6

Same name and namespace in other branches
  1. 7 feeds_oauth.module \feeds_oauth_callback()
1 string reference to 'feeds_oauth_callback'
feeds_oauth_menu in ./feeds_oauth.module
Implementation of hook_menu().

File

./feeds_oauth.module, line 73

Code

function feeds_oauth_callback($site_id) {
  $fetcher = feeds_importer($_SESSION['feeds']['id'])->fetcher;
  $config = $fetcher
    ->getConfig();
  $oauth = new OAuth($config['consumer_key'], $config['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
  $request_token_secret = $_SESSION['feeds']['request_token_info']['oauth_token_secret'];
  if (!empty($_GET['oauth_token'])) {
    $oauth
      ->setToken($_GET['oauth_token'], $request_token_secret);
    $access_token_info = $oauth
      ->getAccessToken($config['access_token_url']);
    global $user;
    db_query("DELETE FROM {feeds_oauth_access_tokens} WHERE uid = %d AND site_id = '%s'", $user->uid, db_escape_string($site_id));
    db_query("INSERT INTO {feeds_oauth_access_tokens} (uid, site_id, oauth_token, oauth_token_secret) VALUES(%d, '%s', '%s', '%s')", $user->uid, db_escape_string($site_id), $access_token_info['oauth_token'], $access_token_info['oauth_token_secret']);
  }
  drupal_goto('import/' . $id);
}