public function GetRecentAnswers($user_id) { global $myUser; // Get the last question in the DB for this user $this->ResetValues(); $this->SetValue('user_id', $user_id); $last_question = current($this->GetAssoc('question_id', 'question_id', 'DESC', 0, 1)); // Start the API connection $connection = new FormspringOAuth(CONSUMER_KEY, CONSUMER_SECRET, $myUser->GetValue('oauth_token'), $myUser->GetValue('oauth_token_secret')); // Grab new items in the inbox $inbox = $connection->get('answered/list/' . $myUser->GetValue('username'), array('since_id' => ltrim($last_question, '0'))); $max_id = 0; $total_imported = 0; do { // If we have to get older items if ($max_id != 0) { $inbox = $connection->get('answered/list/' . $myUser->GetValue('username'), array('max_id' => $max_id)); } // Loop through and make sure the questions are in the database if (is_array($inbox->response)) { foreach ($inbox->response as $answer) { if ($answer->id > (int) $last_question) { // Set all the values for the database $this->ResetValues(); $this->SetValue('question_id', str_pad($answer->id, 24, '0', STR_PAD_LEFT)); $this->SetValue('question', $answer->question); $this->SetValue('answer', $answer->answer); $this->SetValue('date_asked', date('Y-m-d H:i:s', strtotime($answer->time))); $this->SetValue('user_id', $myUser->GetPrimary()); // Save the new answer if (!$this->Save()) { throw new SimplException('Error saving answer to database', 2, 'Error: Saving answer to database: ' . $answer->id); } $total_imported++; } $max_id = $answer->id; } } } while ($max_id != 0 && is_array($inbox->response) && count($inbox->response) > 0); return $total_imported; }
<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/../inc/application_top.php'; if (!isset($_GET['oauth_token'])) { throw new SimplException('A Technical Error has Occurred. Please try again.', 2, 'Error: Tried to use callback without GET token.', '/'); } $myUser = new User(); $myAccountInfo = new AccountInfo(); $myAccountAccess = new AccountAccess(); // Make the temp conenction $connection = new FormspringOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['temporary_credentials']['oauth_token'], $_SESSION['temporary_credentials']['oauth_token_secret']); // Get the long lasting token credentials $token_credentials = $connection->getAccessToken($_GET['oauth_verifier']); // Grab the details of this user $details = $connection->get("profile/details"); // Save it to the database $myUser->ResetValues(); // Check to see if this user is already in the DB $myUser->SetValue('username', $details->response->username); $myUser->GetInfo(NULL, array('username')); // Add the new token credentials $myUser->SetValue('oauth_token', $token_credentials['oauth_token']); $myUser->SetValue('oauth_token_secret', $token_credentials['oauth_token_secret']); // Create a unique ID for the session $myUser->SetValue('sessionid', uniqid()); // Update the user information if found or insert if new if (!$myUser->Save()) { throw new SimplException('Error Saving Formspring Client Token', 2, 'Error: Error Saving Formspring Client Token :' . $details->response->username); } // Set the session cookie if (!isset($_GET['delegate'])) {
<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/../inc/application_top.php'; $connection = new FormspringOAuth(CONSUMER_KEY, CONSUMER_SECRET, '', ''); if (isset($_GET['query']) && trim($_GET['query']) != '') { $list = $connection->get("search/profiles", array('query' => trim($_GET['query']))); } //Pre($myUser->Nice()); //Pre($myAccountInfo->Nice()); include_once DIR_ABS . '../inc/application_bottom.php'; /* $inbox = $connection->get("inbox/list"); echo '<pre>'; print_r($inbox); echo '</pre>'; $details = $connection->get("profile/details/waynestate"); echo '<pre>'; print_r($details); echo '</pre>'; echo '<pre>'; print_r($connection); echo '</pre>'; */ // Display the Index Page $smarty->display('home.tpl');
<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/../inc/application_top.php'; // Make the temp conenction $connection = new FormspringOAuth(CONSUMER_KEY, CONSUMER_SECRET); // Get the temp credentials $temporary_credentials = $connection->getRequestToken(OAUTH_CALLBACK . (isset($_GET['delegate']) && $_GET['delegate'] != '' ? '?delegate=' . $_GET['delegate'] : '')); // Save the temp credentials to the session $_SESSION['temporary_credentials'] = $temporary_credentials; // Determine the redirect URL. $redirect_url = $connection->getAuthorizeURL($temporary_credentials); // Move the user along header('Location: ' . $redirect_url, true, 302); die;