LinkedIn 与 Pecl OAuth:“收到 400,预期 HTTP/1.1 20X 或重定向”
我在 Debian 机器上安装了带有 PHP5 的 Pecl OAuth,并尝试向 LinkedIn 进行身份验证。打电话时;
OAuth->getAccessToken('https://api.lin...')\n#1
我明白了;
PHP 致命错误:未捕获异常“OAuthException”,消息“无效的身份验证/错误请求(收到 400,预期 HTTP/1.1 20X 或重定向)”
我已经从头开始尝试过,并且尝试了可用的 PHP API 包装器(当然,因为他们使用 OAuth Pecl ext)都有同样的问题。
我在某处读到它可能是服务器上的时间戳,但我将其与 ntpdate 同步;现在它经常这样做,所以时间服务器的偏移量几乎为0。
我首先尝试了这个类; http ://www.linkedphp.com/2009/11/26/first-release-classes-to-connect-with-php-to-linkedin-api/,评论中有人有同样的问题,但是该课程的创建者说“你有登录屏幕吗”;我没有,我收到一次“授予或拒绝”屏幕,然后出现空白屏幕并在日志中出现上述错误。
还能是什么?
谢谢
I have Pecl OAuth with PHP5 on a Debian box and I try to authenticate to LinkedIn. When calling;
OAuth->getAccessToken('https://api.lin...')\n#1
I get;
PHP Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)'
I have tried it from scratch and I have tried the PHP API wrappers that are available and (ofcourse, because they use OAuth Pecl ext) have all the same problem.
I read somewhere it might be the timestamp on the server, but I synched that up with ntpdate; it does that quite often now, so the offset with the timeservers is almost 0.
I tried this class first; http://www.linkedphp.com/2009/11/26/first-release-classes-to-connect-with-php-to-linkedin-api/, someone in the comments has the same problem, however the creator of the class says 'do you get a login screen'; I don't, I get a 'Grant or Deny' screen once, after that a blank screen and the above error in my logs.
What else can it be?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,确认了。时间戳是问题所在。
确保您的服务器日期/时间与世界其他地方同步(我使用时间服务器主机名或地址:ntp.cpsc.ucalgary.ca)
注意:我开始认为整个 oauth 事情是一件糟糕的、复杂的事情:)
Yep, confirmed. Timestamp IS the problem.
Make sure your server date/time is in sync with the rest of the world (i use Timeserver hostnames or addresses: ntp.cpsc.ucalgary.ca )
nb: I'm starting to think that this whole oauth thing is a bad , complicated thing :)
你应该发布你的代码。
除了时间戳问题之外,请求中缺少 callbacl URL 也会导致此错误。
You should post your code.
Besides the timestamp issues, missing callbacl URL in the request can also cause this error.
尝试使用以下格式:
其中 $token 是 5 位确认码
Try using the format:
where $token is the 5 digit confirmation code