Twitter Login And Tweet

I have a twitter login script how can i modify it so that when the person use it to login to my site it tweets a message into there account and follow me.

<?php
/**
 * twitter authentication script based on
 * pecl oauth extension
 */
session_start();
include_once("config.php");
/*
unset($_SESSION['trequest_token_secret']);
unset($_SESSION['taccess_oauth_token']);
unset($_SESSION['taccess_oauth_token_secret']);
 */
$oauthc = new OAuth($oauth['twitter']['consumerkey'],
        $oauth['twitter']['consumersecret'],
        OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI); //initiate
if(empty($_SESSION['trequest_token_secret'])) {
    //get the request token and store it
    $request_token_info = $oauthc->getRequestToken($oauth['twitter']['requesttokenurl']); //get request token
    $_SESSION['trequest_token_secret'] = $request_token_info['oauth_token_secret'];
    header("Location: {$oauth['twitter']['authurl']}?oauth_token=".$request_token_info['oauth_token']);//forward user to authorize url
}
else if(empty($_SESSION['taccess_oauth_token'])) {
    //get the access token - dont forget to save it 
    $request_token_secret = $_SESSION['trequest_token_secret'];
    $oauthc->setToken($_REQUEST['oauth_token'],$request_token_secret);//user allowed the app, so u
    $access_token_info = $oauthc->getAccessToken($oauth['twitter']['accesstokenurl']);
    $_SESSION['taccess_oauth_token']= $access_token_info['oauth_token'];
    $_SESSION['taccess_oauth_token_secret']= $access_token_info['oauth_token_secret'];
}
if(isset($_SESSION['taccess_oauth_token'])) {
    //now fetch current users profile
    $access_token = $_SESSION['taccess_oauth_token'];
    $access_token_secret =$_SESSION['taccess_oauth_token_secret'];
    $oauthc->setToken($access_token,$access_token_secret);
    $data = $oauthc->fetch('http://twitter.com/account/verify_credentials.json');
    $response_info = $oauthc->getLastResponse();
    echo "<pre>";
    print_r(json_decode($response_info));
    echo "</pre>";
}
?>

Twitter login script may also keep your account secured. But, I am also interested on how we are going to modify the twitter login. If ever that someone will be interested to log in on a particular site, there will be corresponding tweets that will follow. I found automatic twitter status update script - twitter script to login and tweet, but this is not what I need.

Sponsor our Newsletter | Privacy Policy | Terms of Service