我正在对 Walmart.IO 身份验证错误进行故障排除。我在 Walmart.io 上创建了一个应用程序,获得了客户 ID,我下载了 PuttyGen 并创建了公钥和私钥,并将 .pem 文件保存在项目的文件夹中。
<?php
$consumer_id = '080ece23-73fd-40a2-9e60-a845b6864f7a';
$sec_key_version = '1'; // Here comes you key version
$private_key_file = 'WM_IO_private_key.pem';
$url = 'https://developer.api.walmart.com/api-proxy/service/affil/product/v2/taxonomy';
$timestamp = time()*1000;
$message = $consumer_id."\n".$timestamp."\n".$sec_key_version."\n";
$pkeyid = openssl_pkey_get_private(str_replace("\r", "", file_get_contents($private_key_file)), 'Glocom-WL');
openssl_sign($message, $signature, $pkeyid, OPENSSL_ALGO_SHA256);
$signature = base64_encode($signature);
$signature = str_replace("\r", "", $signature);
openssl_free_key($pkeyid);
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'WM_SEC.KEY_VERSION: '.$sec_key_version,
'WM_CONSUMER.ID: '.$consumer_id,
'WM_CONSUMER.INTIMESTAMP: '.$timestamp,
'WM_SEC.AUTH_SIGNATURE: '.$signature
),
));
$responseObj = curl_exec($curl);
if(curl_exec($curl) === false)
{
echo 'Curl error: ' . curl_error($curl);
}
else
{
echo 'Operation completed without any errors, you have the response';
}
echo "<pre>"; print_r($responseObj);
curl_close($curl);
当我运行代码时出现错误:“{“details”:{“Description”:“无法在请求中进行身份验证,身份验证签名:签名验证失败:affil-product,版本:2.0.0,env:prod ","wm_svc.version":"2.0.0","wm_svc.name":"affil-product","wm_svc.env":"prod"}}"
有人可以帮我弄清楚我能做些什么来解决这个问题吗?