问题
I'm trying to use PHP's Oauth module to interact with Etsy's API.
Following Etsy's docs, I have
<?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"
);
This works fine when run with php7.2:
php7.2 etsy-oauth.php
...
OK
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
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
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.
How should this Oauth call be made correctly in PHP 7.3?
回答1:
I had same problem in php7.3. Try to install OAuth 2.0.5. It work for me
来源:https://stackoverflow.com/questions/58890514/php-oauth-gets-401-on-php-7-3-ok-on-php-7-2-and-earlier