douyan1896 2011-08-09 13:44
浏览 42

EpiTwitter验证错误

So first things first, here's the code:

$consumer_key = '*';
$consumer_secret = '*';

$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$oauth_token = $_GET['oauth_token'];

if($oauth_token == ""){
    echo "EFF";
    $url = $twitterObj->getAuthenticateUrl();
    echo "<div style='width:200px;margin-top:200px;margin-left:auto;margin-right:auto'>";
    echo "<a href='$url'>Sign In with Twitter</a>";
    echo "</div>";
}else{
    $twitterObj->setToken($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('/account/verify_credentials.json');
    $res = $twitterInfo->response; //valid session
    echo "<strong>".$res['screen_name'] . " is Connected!</strong><br/>";
}

It uses the latest EpiTwitter library. For some reason, every time I try to run the script I get:

Fatal error: Uncaught exception 'EpiOAuthUnauthorizedException' in /var/www/twt/EpiOAuth.php:432 Stack trace: #0 /var/www/twt/EpiOAuth.php(404): EpiOAuthException::raise(Object(EpiCurlManager), false) #1 /var/www/twt/EpiOAuth.php(45): EpiOAuthResponse->__get('oauth_token') #2 /var/www/twt/twt.php(18): EpiOAuth->getAuthenticateUrl() #3 {main} thrown in /var/www/twt/EpiOAuth.php on line 432

  • 写回答

2条回答 默认 最新

  • doqau82086 2011-08-10 21:22
    关注

    https://github.com/jmathai/twitter-async/issues/73

    I found if i did, the below, the errors went away.

    try{ 
     $twitterInfo = $twitterObj->get('/account/verify_credentials.json');
     $res = $twitterInfo->response; //valid session
    } catch(EpiTwitterException $e){
     // this catches all of the EpiTwitter* exceptions
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测