0

我尝试使用 Epi twitter 进行登录,这是代码

    $consumerKey = $this->consumerKey ;
    $consumerSecret = $this->consumerSecret;        
    include 'application/libraries/twitter-oauth/EpiCurl.php';
    include 'application/libraries/twitter-oauth/EpiOAuth.php';
    include 'application/libraries/twitter-oauth/EpiTwitter.php';
    error_reporting(E_ALL);

    $Twitter = new EpiTwitter($consumerKey, $consumerSecret);

    if(isset($_GET['oauth_token']) || (isset($_COOKIE['oauth_token']) && isset($_COOKIE['oauth_token_secret'])))
    {
              // process
    }
    elseif(isset($_GET['denied']))
    {
        // user denied access
        echo 'You must sign in through twitter first';
        exit;
    }
    else
    {
        // user not logged in
        echo 'You are not logged in';
        exit;
    }   

但总是响应是“你没有登录 ini”,尽管我已经在其他页面上登录了 twitter。我的代码有问题吗?

感谢任何帮助。

问候

4

1 回答 1

0

当您对用户进行身份验证时,请保存他们的 authToken 和 authTokenSecret。无论是在会话/数据库/cookie 中,都由您决定。

然后,当您创建 EpiTwitter 类的新实例时,传递这两个新参数会膨胀。

$Twitter = new EpiTwitter($consumerKey, $consumerSecret, $userAuthToken, $userTokenSecret);

查看您正在调用的 __construct 函数的参数,

  public function __construct($consumerKey = null, $consumerSecret = null, $oauthToken = null, $oauthTokenSecret = null)
  {
    parent::__construct($consumerKey, $consumerSecret, self::EPITWITTER_SIGNATURE_METHOD);
    $this->setToken($oauthToken, $oauthTokenSecret);
  }
于 2013-04-01T16:26:25.303 回答