Neteller Rest Api

时间:2014-11-07 22:05:19

标签: php rest payment-gateway

我一直在使用Neteller的rest API。我一直在努力为验证密钥获得正确的响应,我希望有人能指出我正确的方向。

$curl = curl_init();

curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, "https://api.neteller.com/v1/oauth2/token?grant_type=client_credentials");
curl_setopt($curl, CURLOPT_USERPWD, "clientId:clientSecret");
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type:application/json", "Cache-Control:no-cache"));
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query("scope: default"));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$serverOutput = curl_exec($curl);

echo $serverOutput;

我得到的回复是“invalid_client”。我检查了clientId和secret,它们是正确的

由于 卡勒姆

4 个答案:

答案 0 :(得分:1)

我只是举个例子,它为我工作:

$username = 'MerchantXYZ';
$password = 'B81dff9bb4020a89e8ac44cdfdcecd702151182fdc952272661d290ab2e5849e31bb03deede';
$curl = curl_init();

curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, "https://api.neteller.com/v1/oauth2/token?grant_type=client_credentials");
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type:application/json", "Cache-Control:no-cache"));
curl_setopt($curl, CURLOPT_POSTFIELDS, array("scope"=>"default"));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$serverOutput = curl_exec($curl);

echo $serverOutput;

回应:

  

{" accessToken":" B.AQBBBAAAUnzfOwkAAAAAAAAEk-BRM0QBTOoehaumwlvdwjqX.EAAQ0NOOTDeY2aMHUCwH4YCugGUX4ro"," tokenType":" Bearer"," expiresIn":300}

问候。

答案 1 :(得分:1)

您不发送参数,但字符串" clientId:clientSecret":

也许你的意思是:

curl_setopt($curl, CURLOPT_USERPWD, "$clientId:$clientSecret");

此外,您可能正在调用错误的网址,例如您必须致电的测试环境:

curl_setopt($curl, CURLOPT_URL, "https://test.api.neteller.com/v1/oauth2/token?grant_type=client_credentials");

答案 2 :(得分:0)

您的CURLOPT_POSTFIELDS无效,因为http_build_query()期望数组作为输入,但您提供的是字符串。

尝试将该行更改为:

curl_setopt($curl, CURLOPT_POSTFIELDS, array("scope"=>"default"));

答案 3 :(得分:0)

使用client_credentials流时,范围不相关。它仅适用于authorization_grant流程,任何标记为'默认'范围不需要会员授权。资源与默认'将使用基本的client_credentials返回,无需向成员请求许可。