Php Neteller Rest Api

Php Neteller Rest Api,php,rest,payment-gateway,Php,Rest,Payment Gateway,我一直在使用Neteller的RESTAPI。我一直在努力获得认证密钥的正确响应,我希望有人能给我指出正确的方向 $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_

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

$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;
我得到的回答是“无效的客户端”。我已经检查了客户ID和密码,它们是正确的

谢谢
Callum

您的
CURLOPT\u POSTFIELDS
无效,因为
http\u build\u query()
需要一个数组作为输入,但您提供的是一个字符串

尝试将该行更改为:

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

我只是以你为例,它对我很有用:

$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.aqbbbaaunzfowkaaaaaaaaaek-BRM0QBTOoehaumwlvdwjqX.eaaq0nootdey2amhuch4ycuggux4ro”,“tokenType”:“持票人”,“到期人”:300}


注意。

使用客户端凭据流时,范围不相关。它只适用于授权授予流,任何标记为“默认”范围的内容都不需要成员授权。将使用基本客户端凭据返回具有“default”的资源域,无需向成员请求权限。

您不发送参数,而是发送字符串“clientId:clientSecret”:

也许你的意思是:

curl_setopt($curl, CURLOPT_USERPWD, "$clientId:$clientSecret");
此外,您可能调用了错误的url,例如,对于必须调用的测试环境:

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

你好,谢谢你的帮助!我已经相应地更改了线路,但仍然收到相同的错误。您的IP可能已被阻止。请看我的回答: