$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;我正在使用这段代码,但每次都向我展示{ "error": "invalid_client" }这条消息。我检查了我的API和IP地址,一切都很完美。
发布于 2015-04-20 12:56:18
在尝试获取令牌时,您可能会得到{ "error": "invalid_client" },原因有4个。
检查点1) - 3);从您的示例中可以看出,您可以将第4点排除为可能的原因。
另外,你也不需要这句话:
curl_setopt($curl, CURLOPT_POSTFIELDS, array("scope"=>"default"));根据文档,在获得令牌时,不应该在请求正文中发布任何内容。你从哪里得到这个例子的?
https://stackoverflow.com/questions/29666028
复制相似问题