尝试通过PHP请求托管支付字段访问令牌时收到401身份验证访问错误。我遵循了这篇教程,-> Easy start with BlueSnap hosted payment fields;阅读了关于-> 1. BlueSnap integration with node js and angular 2. Error getting payment_field_token in Bluesnap API的类似问题,并阅读了基本的身份验证信息http://developers.bluesnap.com/docs/authentication,但没有走运。有谁能弄明白这一点吗?
<?php
$TokenRequest=curl_init();
curl_setopt($TokenRequest, CURLOPT_URL, "https://sandbox.bluesnap.com/services/2/payment-fields-tokens");
curl_setopt($TokenRequest, CURLOPT_HEADER, 1);
curl_setopt($TokenRequest, CURLOPT_HTTPHEADER, array("Authorization: Basic CREDENTIALS_HERE", "Content-type: application/json"));
curl_setopt($TokenRequest, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($TokenRequest, CURLOPT_RETURNTRANSFER, true);
$TokenResponse=curl_exec($TokenRequest);
list($Headers, $Response)=explode("\r\n\r\n", $TokenResponse, 2);
$Headers=explode("\n", $Headers);
foreach($Headers as $Header)
{
if (stripos($Header, "Location")!==false)
{
$Token=trim(str_replace("Location: ", "", $Header));
}
}
?>发布于 2018-05-04 23:12:53
我为BlueSnap工作。
401错误通常意味着权限问题。您是否在BlueSnap控制台中将您的IP列入白名单。关于如何做到这一点的文档可以在这里找到:https://developers.bluesnap.com/docs/api-credentials。如果您可以向我提供正在发送的实际JSON对象(或XML),我可以尝试跟踪确切的错误,并尝试确定根本原因。
我找到了你的API调用,你正在做的是GET而不是POST。创建调用POST所需的令牌。
https://stackoverflow.com/questions/50176915
复制相似问题