function acquire_poll($url) { // acquire request token and access token for future requests $token_string = request_token(); $token_string2 = access_token($token_string); $tokens = form_tokens($token_string, $token_string2); // retrieve poll's 16-character id $id = extract_id($url); // access this poll $poll = access_poll($id, $tokens); // format poll data $xml_array = parse($poll); // store tokens for future use in submitting poll $xml_array['tokens'] = $tokens; return $xml_array; }
?> <p>Congratulations, below is the user token and secret for @<?php echo htmlspecialchars($oauth_creds['screen_name']) ?>. Use these to make authenticated calls to Twitter using the application with consumer key: <?php echo htmlspecialchars($tmhOAuth->config['consumer_key']) ?></p> <p>User Token: <?php echo htmlspecialchars($oauth_creds['oauth_token']) ?><br /> User Secret: <?php echo htmlspecialchars($oauth_creds['oauth_token_secret']) ?></p> <?php*/ } return false; } $params = uri_params(); if (!isset($params['oauth_token'])) { // Step 1: Request a temporary token and // Step 2: Direct the user to the authorize web page request_token($tmhOAuth); } else { // Step 3: This is the code that runs when Twitter redirects the user to the callback. Exchange the temporary token for a permanent access token $oauth_creds = access_token($tmhOAuth); if ($oauth_creds && isset($oauth_creds['oauth_token']) && !empty($oauth_creds['oauth_token']) && isset($oauth_creds['oauth_token_secret']) && !empty($oauth_creds['oauth_token_secret'])) { // yay we're connected to twitter! // write these to the database so we can do stuff on the backend. $twitter_account->update('twitter_name', $oauth_creds['screen_name']); $twitter_account->update('twitter_id', $oauth_creds['user_id']); $twitter_account->update('user_key', $oauth_creds['oauth_token']); $twitter_account->update('user_secret', $oauth_creds['oauth_token_secret']); $twitter_account->update('last_checked', time()); set_message('Successfully connected to Twitter'); redirect_browser(module_social_twitter::link_open($social_twitter_id)); } else { echo 'Failed to connect to twitter';
// If there was an error saving the account to the API if (is_array($account_response['response']['error'])) { Flash($account_response['response']['error']['message'], 'error'); } else { Flash('Account "' . $account_response['response']['twitter']['screen_name'] . '" added successfully!'); } } //header('Location: ' . php_self()); //die(); } } $params = uri_params(); if (!isset($params['oauth_token'])) { // Step 1: Request a temporary token and // Step 2: Direct the user to the authorize web page $twitter_request_url = request_token($tmhOAuth); } else { // Step 3: This is the code that runs when Twitter redirects the user to the callback. Exchange the temporary token for a permanent access token access_token($tmhOAuth); } // Get a list of all the account this user has access to $account_list = $c->sendRequest('socialy/account/listing', array(), 'get'); $access_list = $c->sendRequest('socialy/account/access', array('notowner' => 'true'), 'get'); //Pre($access_list); include_once ROOT . '/_header.php'; ?> <div class="row-fluid" id="content"> <div class="span9"> <div class="list-view"> <div class="list-header well">