duanjiaopi8218 2013-07-02 23:46
浏览 110
已采纳

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

I have thus far been able to transmit a state in Google+ oAuth2, and Yahoo oAuth2, and even myopenid. Now I am at the Twitter stage of my provider login project.

I am using the three classes developed by @jmathai (tutorial here).

My signin code looks very similar to this:

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>';

It works pretty well. But I need to pass some state parameters, like a client id, an origin page url, and some other junk.

I don't see how this is done with the epicurl libraries.

  • 写回答

1条回答 默认 最新

  • dongqiangou5724 2013-07-03 00:55
    关注

    Answering my own question. You can pass an entire query string, along with the url (although the page script should be the same as the callback page you specified in your Twitter app setup...I think).

    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);
    

    ...and that's how it's done.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站