0
我使用EPI Twitter Oauth方法設置網站。我可以讓用戶登錄並檢索他們的信息。但是,當我刷新具有其信息的頁面時,信息會丟失。我猜這是關於訪問令牌的,希望有人能提出解決這個問題的最簡單方法。在Epi Twitter保留訪問令牌Twitter Oauth
<?php
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 "<div id=\"container\">";
echo "<div id=\"content\">";
echo "<div id=\"holder\">";
echo "</div>";
echo "<div id=\"nav\">";
echo "<a href='$url'><img src=\"signup.jpg\" class=\"linkimage\" /></a>";
echo "</div>";
echo "</div>";
echo "</div>";
}
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 'home.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;
echo "<br /><div align='center'>Updated your Timeline Successfully .</div>";
}
?>