Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Epi Twitter Oauth中保留访问令牌_Twitter_Twitter Oauth - Fatal编程技术网

在Epi Twitter Oauth中保留访问令牌

在Epi Twitter Oauth中保留访问令牌,twitter,twitter-oauth,Twitter,Twitter Oauth,我正在使用EPI Twitter Oauth方法建立一个网站。我能够让用户登录并检索他们的信息。但是,当我刷新包含他们信息的页面时,信息将丢失。我猜这与访问令牌有关,我希望有人能建议最简单的解决方法 <?php include 'lib/EpiCurl.php'; include 'lib/EpiOAuth.php'; include 'lib/EpiTwitter.php'; include 'lib/secret.php'; $twitterObj = new EpiTwitte

我正在使用EPI 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>";

 }

?>

在我看来,您只是在检查oauth令牌的
$\u GET
。我认为这可能会导致“丢失信息”问题,因为在刷新页面时,oauth令牌已存储在会话变量中,并且可能不再存储在URL中。我认为您可能需要替换以下内容:

$oauth_token = $_GET['oauth_token'];

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