gpt4 book ai didi

php - 亚马逊 API 从产品中获取所有图像

转载 作者:行者123 更新时间:2023-12-04 17:47:00 28 4
gpt4 key购买 nike

我有一个简单的问题,因为没有找到任何答案。实际上,我可以使用亚马逊的 API 从 ASIN 代码中获取有关产品的信息,但在这张图片的情况下,我可以获得一张不同格式的图片,大拇指、中拇指等,对吗?

在我的例子中,我想知道是否有可能从产品中获取所有图片,而不是只显示 1 张不同格式的图片,如果我可以使用抓取获取所有图片,但在这种情况下我想使用 API,因为它是更干净,而且使用抓取的 CURL 的许多查询没有问题

实际上我用这个:

$gallery=htmlentities((string) $item->ImageSets->ImageSet->LargeImage->URL);

项目结构:

$item = $xml->Items->Item;
$title = htmlentities((string) $item->ItemAttributes->Title);
$url = htmlentities((string) $item->DetailPageURL);
$image = htmlentities((string) $item->MediumImage->URL);
$price = htmlentities((string) $item->OfferSummary->LowestNewPrice->Amount);
$amount=htmlentities((string) $item->OfferSummary->LowestNewPrice->Amount);
$item->OfferSummary->LowestUsedPrice->Amount);
$code = htmlentities((string) $item->OfferSummary->LowestNewPrice->CurrencyCode);
$qty = htmlentities((string) $item->OfferSummary->TotalNew);
$gallery=htmlentities((string) $item->ImageSets->ImageSet->LargeImage->URL);

函数 API 代码:

function getAmazonPrice($region, $asin) 
{
global $precioamz;
global $amountamz;
global $imageamz;
global $galeriaamz;

$xml = aws_signed_request($region, array(
"Operation" => "ItemLookup",
"ItemId" => $asin,
"IncludeReviewsSummary" => False,
"ResponseGroup" => "Medium,OfferSummary",
));

$item = $xml->Items->Item;
$title = htmlentities((string) $item->ItemAttributes->Title);
$url = htmlentities((string) $item->DetailPageURL);
$image = htmlentities((string) $item->MediumImage->URL);
$price = htmlentities((string) $item->OfferSummary->LowestNewPrice->Amount);
$amount=htmlentities((string) $item->OfferSummary->LowestNewPrice->Amount);
$item->OfferSummary->LowestUsedPrice->Amount);
$code = htmlentities((string) $item->OfferSummary->LowestNewPrice->CurrencyCode);
$qty = htmlentities((string) $item->OfferSummary->TotalNew);
$gallery=htmlentities((string) $item->ImageSets->ImageSet->LargeImage->URL);

/// $gallery=Images,ItemAttributes,Variations,VariationImages


if ($qty !== "0")
{
$response = array(
"code" => $code,
"price" => number_format((float) ($price / 100), 2, '.', ''),
"image" => $image,
"url" => $url,
"title" => $title,
"amount" => $amount,
"galeria" => $gallery
);
}

$precioamz=$response['price'];
$amountamz=$response['amount'];
$imageamz=$response['image'];
$galeriaamz=$response['galeria'];

//return $response;
}

function getPage($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$html = curl_exec($curl);
curl_close($curl);
return $html;
}

但是只能得到一张图片,我想得到这个产品的所有图片,谢谢你的帮助,问候

最佳答案

获取你必须使用或添加的所有图像

Images,ItemAttributes,Variations,VariationImages 作为请求键 ResponseGroup 的值,当您调用 aws_signed_request()

我当然希望得到与您现在得到的不同的响应,因此您的响应解析代码可能需要修改。

检查响应并相应地编辑您的代码。

关于php - 亚马逊 API 从产品中获取所有图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48030127/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com