PHP Oauth在PHP 7.3上获得401,在PHP 7.2和更早版本上可以 [英] PHP Oauth gets 401 on PHP 7.3, ok on PHP 7.2 and earlier
问题描述
我正在尝试使用PHP的 Oauth模块进行交互使用Etsy的API.
I'm trying to use PHP's Oauth module to interact with Etsy's API.
按照 Etsy的文档,我有
<?php
if (!extension_loaded('oauth')) {
throw new Exception('Oauth not loaded.');
}
$oauth = new OAuth("foobar-key", "foobar-secret");
$req_token = $oauth->getRequestToken(
"https://openapi.etsy.com/v2/oauth/request_token?scope=email_r%20listings_r",
"oob",
"GET"
);
与php7.2一起运行时,效果很好:
This works fine when run with php7.2:
php7.2 etsy-oauth.php
...
OK
但是当使用php7.3运行相同代码时,我得到401:
When the same is run with php7.3, though, I get a 401:
php7.3 etsy-oauth.php
...
PHP Fatal error: Uncaught OAuthException: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
oauth_problem=signature_invalid
肯定已为PHP 7.2和PHP 7.3安装了OAuth,如上面的extension_loaded
以及通过以下方式确认的:
OAuth is definitely installed for both PHP 7.2 and PHP 7.3, as confirmed by the extension_loaded
above, and by:
php7.2 -m | grep OAuth
OAuth
php7.3 -m | grep OAuth
OAuth
在PHP 7.3与PHP 7.2中如何进行相同的调用方面,我还没有发现任何文献记载的差异.
I haven't been able to find any documented difference in how this same call should be made in PHP 7.3 vs PHP 7.2.
如何在PHP 7.3中正确进行此Oauth调用?
How should this Oauth call be made correctly in PHP 7.3?
推荐答案
我在php7.3中有同样的问题.尝试安装OAuth 2.0.5.它对我有用
I had same problem in php7.3. Try to install OAuth 2.0.5. It work for me
这篇关于PHP Oauth在PHP 7.3上获得401,在PHP 7.2和更早版本上可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!