I'm pretty lost! :)

I've gone through the documents and I've once successfully posted a
tweet. No idea how that happened, however. I'm attempting to do a one-
page validation for this so that I can keep it relatively simple
without redirects.

How can I accomplish this, however? Here is my code, and I'd greatly
appreciate somebody to point out the fallacies. Thank you.


        if(!@$_GET['oauth_token']) {
                $connection = new TwitterOAuth($db['twc_api'], 
$db['twc_secret']);
                $temp = $connection->getRequestToken($OAUTH_CALLBACK);
                $twit_url = $connection->getAuthorizeURL($temp);
                $_SESSION['oauth_request_token'] = $token = 
$temp['oauth_token'];
                $_SESSION['oauth_request_token_secret'] =
$temp['oauth_token_secret'];
        } else {
                if(!isset($_SESSION['oauth_access_token']) ||
$_SESSION['oauth_access_token'] == '') {
                        $connection = new TwitterOAuth($db['twc_api'], 
$db['twc_secret'],
$_SESSION['oauth_request_token'],
$_SESSION['oauth_request_token_secret']);
                        $temp = $connection->getRequestToken();
                        $_SESSION['oauth_access_token'] = $token = 
$temp['oauth_token'];
                        $_SESSION['oauth_access_token_secret'] =
$temp['oauth_token_secret'];
                }
        }

        if(isset($_POST['submit_tweet'])) { # Handle tweet submissions
                $connection = new TwitterOAuth($db['twc_api'], 
$db['twc_secret'],
$_SESSION['oauth_access_token'],
$_SESSION['oauth_access_token_secret']);
                $content = $connection->get('account/verify_credentials');
                $msg = $_REQUEST['tweet'];
                $update_status = $connection->post('statuses/update', array(
                        'status' => $msg.' '.bitly($money_url, 
$db['bitly_login'],
$db['bitly_api'])
                ));
                $tweeted = true;
                print_r($update_status);
                if($update_status->error) echo 'An error occurred';
                else Header('location: '.$reward_url);
        }

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk

Reply via email to