Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/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
Twitter O-Auth回调url_Twitter_Oauth - Fatal编程技术网

Twitter O-Auth回调url

Twitter O-Auth回调url,twitter,oauth,Twitter,Oauth,我对Twitter的oauth身份验证和使用回调url有问题 我用php编写代码,并使用twitter wiki引用的示例代码 我得到了那个代码,并尝试了一个简单的测试,它工作得很好。但是,我希望通过编程指定回调url,而示例不支持这一点 因此,我快速修改了getRequestToken()方法以接受一个参数,现在它看起来如下所示: function getRequestToken($params = array()) { $r = $this->oAuthRequest($this-

我对Twitter的oauth身份验证和使用回调url有问题

我用php编写代码,并使用twitter wiki引用的示例代码

我得到了那个代码,并尝试了一个简单的测试,它工作得很好。但是,我希望通过编程指定回调url,而示例不支持这一点

因此,我快速修改了getRequestToken()方法以接受一个参数,现在它看起来如下所示:

function getRequestToken($params = array()) {
  $r = $this->oAuthRequest($this->requestTokenURL(), $params);
  $token = $this->oAuthParseResponse($r);
  $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
  return $token;
}
我的电话是这样的

$tok = $to->getRequestToken(array('oauth_callback' => 'http://127.0.0.1/twitter_prompt/index.php'));
这是我所做的唯一更改,重定向就像一个符咒,但是当我尝试使用新授予的访问权限尝试拨打电话时,我遇到了一个错误。我收到一个“无法验证您的身份”错误。此外,应用程序从未实际添加到用户授权连接中


现在我阅读了规范,我想我所要做的就是在获取请求令牌时指定参数。有谁能在oauth和twitter方面更老练一点,帮我一把吗?谢谢

Twitter不支持oauth_回调参数,只使用注册应用程序设置中指定的参数

它也不允许在回调中使用127.0.0.1或localhost名称,所以我在DNS中设置了127.0.0.1,这样您就可以安全地使用

http://dev.twipler.com/twitter_prompt/index.php

@伊恩,twitter现在允许127.0.0.1,并且最近做了一些其他的改变

@杰特曼,检查我的答案,看看是否有用

德国劳埃德船级社


叮当声

就连我都犯了401错误。。但是它已经解决了。。 在将应用程序注册到twitter时,您需要提供回调url。。。 喜欢

我已经用java做了这个。。。 所以我的代码是:String CallbackURL=”http://localhost:8080/tweetproj/index.jsp"; provider.RetrieverRequestToken(使用者、回调URL)

其中tweetproj是我的项目名称 jsp只是一个jsp页面


希望这对你有所帮助。

用户在twitter.com上授权应用程序后,他们返回到你的回调URL,你必须将请求令牌交换为访问令牌。

我认为twitter现在已经解决了这一问题,或者你可能没有在应用程序设置中提供默认回调URL,这是动态回调url按照上面提到的方式工作所必需的

在任何情况下,我都是通过在检索请求令牌时传递誓言回调参数来实现这一点的。我正在使用PHP库,必须进行一些小调整,使库通过回调url

如果您使用的是twitter async,则更改如下:

修改了getRequestToken和getAuthenticateURL函数,将回调url作为参数

 public function getRequestToken($callback_url = null)
  {
    $params = empty($callback_url) ? null : array('oauth_callback'=>$callback_url);
    $resp = $this->httpRequest('GET', $this->requestTokenUrl, $params);
    return new EpiOAuthResponse($resp);
  }


 public function getAuthenticateUrl($callback_url = null)
  { 
    $token = $this->getRequestToken($callback_url);
    return $this->authenticateUrl . '?oauth_token=' . $token->oauth_token;
  }
并从PHP代码中传递回调url

$twitterObj->getAuthenticateUrl('http://localhost/twitter/confirm.php');

Twitter根据oauth 1.0a支持动态oauth_回调URL。干杯-这正是我需要的修改。对于任何感兴趣的人来说,这现在是twitter异步的一部分