如何使用epicurl库为Twitter oAuth登录传递状态参数


How to pass state parameters using epicurl libraries for Twitter oAuth signon

到目前为止,我已经能够在Google+oAuth2、Yahoo oAuth2甚至mypenid中传输状态。现在我正处于我的提供者登录项目的Twitter阶段。

我使用的是@jmathai开发的三个类(此处为教程)。

我的登录代码看起来与此非常相似:

include 'EpiCurl.php';
include 'EpiOAuth.php';
include 'EpiTwitter.php';
$consumer_key = 'R4**Fw';
$consumer_secret = 'blp**Z8SA';
$Twitter = new EpiTwitter($consumer_key, $consumer_secret);
echo '<a href="' . $Twitter->getAuthorizeUrl() . '">
<img src="twitterButton.png" alt="sign in with twitter" />
</a>';

它运行得很好。但我需要传递一些状态参数,比如客户端id、原始页面url和其他一些垃圾邮件。

我不知道epicurl库是如何做到这一点的。

回答我自己的问题。您可以传递整个查询字符串和url(尽管页面脚本应该与您在Twitter应用程序设置中指定的回调页面相同……我认为)。

include 'twitter-async-master/EpiCurl.php';
include 'twitter-async-master/EpiOAuth.php';
include 'twitter-async-master/EpiTwitter.php';
$consumer_key = 'R4kZPH********ZCtFw';
$consumer_secret = 'blp***********************klFcZ8SA';
$Twitter = new EpiTwitter($consumer_key, $consumer_secret);
$callback = "http://www.talqo.com/twittercallback.php?callback=".urlencode($_GET['callback'])."&domain=".urlencode($_GET['domain'])."&page=".urlencode($_GET['page'])."&tid=".urlencode($_GET['tid'])."&height=".urlencode($_GET['height'])."&width=".urlencode($_GET['height']);
$Twitter->setCallback($callback);

事情就是这样做的。