1

I have created a twitter app which I am using to post tweets. The problem that I am not able to resolve is everytime I have to allow access to my application.

so lets say I need to tweet three messages, so all the three times I have to allow access to my app.

I just need that once user has allowed access to my app, next time he should only be asked to allow acces is that when he/she relogins.

Here's my code that I am using

  Share content on twitter";

include 'lib/EpiCurl.php';
include 'lib/EpiOAuth.php';
include 'lib/EpiTwitter.php';
include 'lib/secret.php';

        $twitterObj = new EpiTwitter($consumer_key, $consumer_secret);

        $oauth_token = $_GET['oauth_token'];


if($oauth_token == '')
{ 
    $url = $twitterObj->getAuthorizationUrl();
    echo "";
    echo "Sign In with Twitter";
    echo "";
} 
else
{

        $twitterObj->setToken($_GET['oauth_token']);
        $token = $twitterObj->getAccessToken();
        $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);   

        $_SESSION['ot'] = $token->oauth_token;
        $_SESSION['ots'] = $token->oauth_token_secret;
        $twitterInfo= $twitterObj->get_accountVerify_credentials();
        $twitterInfo->response;

    $username = $twitterInfo->screen_name;
    $profilepic = $twitterInfo->profile_image_url;

    include 'update.php';
} 

if(isset($_POST['submit']))
{
    $msg = $_REQUEST['tweet'];

    $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);
    $update_status = $twitterObj->post_statusesUpdate(array('status' => $msg));
    $temp = $update_status->response;


    header("Location: MessageStatus.html");
    exit();
}

?> 
4

1 回答 1

0
在推特上分享内容”;

包括'lib/EpiCurl.php';
包括'lib/EpiOAuth.php';
包括'lib/EpiTwitter.php';
包括'lib/secret.php';

        $twitterObj = new EpiTwitter($consumer_key, $consumer_secret);

        $oauth_token = 空($_SESSION['ot'])?$_GET['oauth_token']:$_SESSION['ot'];


如果($oauth_token == '')
{
    $url = $twitterObj->getAuthorizationUrl();

        回声“”;
        echo "用 Twitter 登录";
        回声“”;


}
别的
{
        如果(空($_SESSION['ot']))
        {
            $twitterObj->setToken($_GET['oauth_token']);
            $token = $twitterObj->getAccessToken();
            $twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);   

            $_SESSION['ot'] = $token->oauth_token;
            $_SESSION['ots'] = $token->oauth_token_secret;
        }
        别的
        {
            $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);   
        }
        $twitterInfo= $twitterObj->get_accountVerify_credentials();
        $twitterInfo->响应;

    $username = $twitterInfo->screen_name;
    $profilepic = $twitterInfo->profile_image_url;

    包括'update.php';
}

if(isset($_POST['submit']))
{
    $msg = $_REQUEST['tweet'];
    尝试 {
    $twitterObj->setToken($_SESSION['ot'], $_SESSION['ots']);
    $update_status = $twitterObj->post_statusesUpdate(array('status' => $msg));
    $temp = $update_status->响应;




     }
    捕获(异常 $e)
    {

    }
}

?>
于 2010-12-23T18:31:47.047 回答