有沃尔玛的开发人员API和SDK,但它们似乎是为电视,家具等一般物品而设计的。有人碰巧知道沃尔玛杂货店是否有SDK或API吗?我的用例是为给定商店以编程方式填充Walmart Grocery购物车。
对于沃尔玛杂货 API,您可以使用 cURL 获取杂货商品列表。在下面提供的示例中,我将使用 PHP(Guzzle/HTTP)
搜索鸡蛋 (PHP)
$client = new Client(['base_uri' => 'https://grocery.walmart.com/v4/api/']);
$method = 'GET';
$path = 'products/search';
$query = [
'query' =>
[
'storeId' => '1855', //store location
'count' => 50,
'page' => 1,
'offset' => 0,
'query' => 'Egg Dozen'
]
];
$req = $client->request($method, $path, $query);
$data = json_decode($req->getBody()->getContents());
$products = $data->products;
print_r($products);
Run Code Online (Sandbox Code Playgroud)
这将根据您的搜索查询列出 50-60 种杂货。
在 cURL 中搜索鸡蛋
curl -X GET \
'https://grocery.walmart.com/v4/api/products/search?storeId=1855&count=1&page=1&offset=0&query=eggs' \
-H 'Postman-Token: 1723fea5-657d-4c54-b245-027d41b135aa' \
-H 'cache-control: no-cache'
Run Code Online (Sandbox Code Playgroud)
不确定这是否回答了您的问题,但我希望这是一个开始。