在我的 WordPress REST 端点上,我登录了 wordpress 以返回一个随机数,如下所示:
PHP
$authenticated = wp_authenticate( $userID , $password );
$isAuthenticated = ( $authenticated instanceof \WP_User ) ? TRUE : FALSE;
if ( $isAuthenticated )
{
$responseData[ "nonce" ] = wp_create_nonce( "rest" );
return rest_ensure_response( $responseData );
}
Run Code Online (Sandbox Code Playgroud)
然后我通过 axios 将随机数返回给 PHP 来验证它并且它有效!
JS:
let axiosSettings = {
baseURL: "http://site.localhost",
url: "/wp-json/id3/test/verify",
method: "POST",
data: {
n: this.state.nonce
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我将随机数放入标头 X-WP-Nonce 时,
let axiosSettings = {
baseURL: "http://site.localhost",
url: "/wp-json/id3/test/pc",
method: "POST",
data: {
n: …Run Code Online (Sandbox Code Playgroud) Bahasa / Indonesia 和他加禄语 / 菲律宾的语言环境是什么?是 id_ID 和 tl_PH 吗?
我看到有些网站提到了 in_ID,但我相信语言环境的“in”是印度。
试图让我的贝宝 REST api 网站上线。它在沙盒模式下运行良好,具有经过验证的传输。
当我为实时客户端 ID 和密钥切换沙箱时,出现错误
{"error":"invalid_client","error_description":"Client Authentication failed"}
Run Code Online (Sandbox Code Playgroud)
我检查并确保我的代码应该上线
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
PP_CLIENT_ID , // ClientID
PP_CLIENT_SECRET // ClientSecret
)
);
// setting mode to live
// https://github.com/paypal/PayPal-PHP-SDK/wiki/Going-Live
$apiContext->setConfig([
'mode' => 'live',
]);
Run Code Online (Sandbox Code Playgroud)
通过 wp_ajax 运行它
任何帮助,将不胜感激!谢谢!
2/5/2019:似乎其他人遇到了这个问题:https : //github.com/paypal/PayPal-PHP-SDK/issues/435
也是我错过的关于 StackOverflow 的同样问题......也没有答案。 PayPal 应用程序与沙盒一样完美运行,客户端身份验证在 Live 上失败:要检查的步骤列表?