laravel-7 - Walmart Api 与 Laravel 7 和自动数字签名创建的集成
问题描述
我正在使用 Laravel 7 进行 Walmart Api 集成。我也安装了 GuzzleHttp。我使用 DigitalSignatureUtil.jar 生成 WM_SEC.AUTH_SIGNATURE 和 WM_SEC.TIMESTAMP。第一次在 json 中获取数据效果很好。以下是代码。
$client = new GuzzleHttp\Client();
$res = $client->request('GET', 'https://marketplace.walmartapis.com/v3/feeds', [
'headers' => [
'WM_SVC.NAME' => 'walmart market place',
'WM_CONSUMER.ID' => '#########',
'WM_QOS.CORRELATION_ID' => '########',
'WM_CONSUMER.CHANNEL.TYPE' => '######',
'WM_SEC.AUTH_SIGNATURE' => '#######',
'WM_SEC.TIMESTAMP' => '1596290047006',
'Content-Type' => 'application/json',
'Accept' => 'application/json',
]
]);
$products = json_decode((string) $res->getBody(), true);
return view('product', compact('products'));
注意:但如果我在第二天或几分钟后使用代码,它会出错。我收到以下错误
GuzzleHttp\Exception\ClientException
Client error: `GET https://marketplace.walmartapis.com/v3/feeds` resulted in a `401 Unauthorized`
response: {"error": [{"code":"UNAUTHORIZED.GMP_GATEWAY_API",
"field":"UNAUTHORIZED","description":"Unauthorized","info":"Unauthorize (truncated...)
请帮助我该怎么做才能摆脱这种情况?
解决方案
推荐阅读
- javascript - Express Session 不会取消设置变量
- java - 尝试在 .jar 导出文件中包含图像
- xaml - 如何在 UWP 中更改 ComboBox 占位符前景
- c# - 带有递归类的 C# 数据注释
- python - 使用 Gekko 最小化矩阵的范数
- here-api - 如何使用这些选项为卡车获取路线 GrossWeight 高度长度
- android - 如何将字符串从 recycleView 适配器传递到片段
- node.js - 节点中的 VSCode Azure 帐户扩展“刷新令牌已过期”
- flutter - 即使用户没有与应用程序交互,如何在 Flutter 中保持长时间运行
- next.js - 错误:`revalidate` 属性还不能用于一般用途