我想得到" offer-listing"使用亚马逊API。 我自己进行了探索,但没有得到它的线索。 如果有人建议我使用API终点来获得商品列表或替代
,那就太好了答案 0 :(得分:0)
您可以废弃产品页面或使用亚马逊产品的API并致电:
此API调用将返回着陆价格,运费价格,上市价格,其中着陆价格是您的销售价格+运费价格。上述API调用中没有一个包含卖家的姓名或任何身份,因此,如果您按照卖家的名义和售价进行操作,则最好不要删除该产品页面。
以下是我使用的代码:
$asin amazon product's ASIN
$sku is amazon product's SKU
$pos_data array contains all Amazon API's credentials
$fba_check is 'Y' or 'N' whether the ASIN is FBA(Fulfilled by Amazon) or not
function init_pro_api($asin, $sku, $pos_data, $fba_check)
{
$try = 0;
while($try < 2)
{
$offers_list = "";
$AWS_ACCESS_KEY_ID = $pos_data['azn_access_key'];
$AWS_SECRET_ACCESS_KEY = $pos_data['azn_secret_access_key'];
$APPLICATION_NAME = $pos_data['azn_app_name'];
$APPLICATION_VERSION = $pos_data['azn_app_version'];
$MERCHANT_ID = $pos_data['azn_merchant_id'];
$MARKETPLACE_ID = $pos_data['azn_marketplace_id'];
$platform = $pos_data['azn_platform_variant'];
if($platform == "uk")
{
$serviceURL = "https://mws.amazonservices.co.uk/Products/2011-10-01";
}
else
$serviceURL = "https://mws-eu.amazonservices.com/Products/2011-10-01";
$DATE_FORMAT = "Y-m-d";
$config = array(
'ServiceURL' => $serviceURL,
'ProxyHost' => null,
'ProxyPort' => -1,
'MaxErrorRetry' => 3,
);
$service = new MarketplaceWebServiceProducts_Client($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY, $APPLICATION_NAME, $APPLICATION_VERSION, $config);
// Get My Price
$request = new MarketplaceWebServiceProducts_Model_GetMyPriceForSKURequest();
$request->setSellerId($MERCHANT_ID);
$request->setMarketplaceId($MARKETPLACE_ID);
$sku_list = new MarketplaceWebServiceProducts_Model_SellerSKUListType();
$sku_list->setSellerSKU($sku);
$request->setSellerSKUList($sku_list);
$my_offer = invokeGetMyPriceForSKU($service, $request, $fba_check);
// Get Other Sellers Lowest Offering Price
$request = new MarketplaceWebServiceProducts_Model_GetLowestOfferListingsForSKURequest();
$request->setSellerId($MERCHANT_ID);
$request->setMarketplaceId($MARKETPLACE_ID);
$request->setItemCondition("New");
$request->setExcludeMe(TRUE);
$sku_list = new MarketplaceWebServiceProducts_Model_SellerSKUListType();
$sku_list->setSellerSKU($sku);
$request->setSellerSKUList($sku_list);
$other_low_offers = invokeGetLowestOfferListingsForSKU($service, $request);
if($my_offer != "" or $my_offer != NULL)
{
$offers_list["MyOffer"] = $my_offer;
}
if($other_low_offers != "" or $other_low_offers != NULL)
{
$offers_list["OtherOffer"] = $other_low_offers;
}
if(isset($offers_list["OtherOffer"][0]))
if($offers_list["OtherOffer"][0] != "")
break;
$try++;
}
return $offers_list;
}
function invokeGetMyPriceForSKU(MarketplaceWebServiceProducts_Interface $service, $request, $fba_check)
{
try
{
$my_response_data = "";
$pre_check_xml_data = array();
$xml_feed_counter = 0;
$response = $service->GetMyPriceForSKU($request);
$dom = new DOMDocument();
$dom->loadXML($response->toXML());
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$xml_data = $dom->saveXML();
$doc = new DOMDocument;
$doc->preserveWhiteSpace = FALSE;
$doc->loadXML($xml_data);
$offer_length = $doc->getElementsByTagName('Offer')->length;
$fba_index = "";
$normal_index = "";
for($o = 0; $o < $offer_length; $o++)
{
$pre_check_xml_data[$o]["LandedPrice"] = $doc->getElementsByTagName('LandedPrice')->item($o)->lastChild->nodeValue;
$pre_check_xml_data[$o]["ListingPrice"] = $doc->getElementsByTagName('ListingPrice')->item($o)->lastChild->nodeValue;
$pre_check_xml_data[$o]["Shipping"] = $doc->getElementsByTagName('Shipping')->item($o)->lastChild->nodeValue;
$pre_check_xml_data[$o]["FulfillmentChannel"] = $doc->getElementsByTagName('FulfillmentChannel')->item($o)->nodeValue;
if($fba_check == "Y")
{
if($doc->getElementsByTagName('FulfillmentChannel')->item($o)->nodeValue == "AMAZON")
{
$fba_index = $o;
break;
}
}
elseif($fba_check == "N")
{
if($doc->getElementsByTagName('FulfillmentChannel')->item($o)->nodeValue == "MERCHANT")
{
$normal_index = $o;
break;
}
}
}
if($fba_check == "Y")
{
if($fba_index === "")
{
$my_response_data[0]["LandedPrice"] = "";
$my_response_data[0]["ListingPrice"] = "";
$my_response_data[0]["Shipping"] = "";
$my_response_data[0]["Fulfillment"] = "";
return $my_response_data;
}
else
{
$my_response_data[0] = $pre_check_xml_data[$fba_index];
return $my_response_data;
}
}
else
{
$my_response_data[0] = $pre_check_xml_data[$normal_index];
return $my_response_data;
}
}
catch(MarketplaceWebServiceProducts_Exception $ex)
{
echo("Caught Exception: " . $ex->getMessage() . "\n");
echo("Response Status Code: " . $ex->getStatusCode() . "\n");
echo("Error Code: " . $ex->getErrorCode() . "\n");
echo("Error Type: " . $ex->getErrorType() . "\n");
echo("Request ID: " . $ex->getRequestId() . "\n");
echo("XML: " . $ex->getXML() . "\n");
echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
}
}
function invokeGetLowestOfferListingsForSKU(MarketplaceWebServiceProducts_Interface $service, $request)
{
try
{
$response_data = "";
$counter = 0;
$response = $service->getLowestOfferListingsForSKU($request);
$getLowestOfferListingsForSKUResultList = $response->getGetLowestOfferListingsForSKUResult();
foreach($getLowestOfferListingsForSKUResultList as $getLowestOfferListingsForSKUResult)
{
if($getLowestOfferListingsForSKUResult->isSetProduct())
{
$product = $getLowestOfferListingsForSKUResult->getProduct();
if($product->isSetLowestOfferListings())
{
$lowestOfferListings = $product->getLowestOfferListings();
$lowestOfferListingList = $lowestOfferListings->getLowestOfferListing();
foreach($lowestOfferListingList as $lowestOfferListing)
{
if($lowestOfferListing->isSetQualifiers())
{
$qualifiers = $lowestOfferListing->getQualifiers();
if($qualifiers->isSetFulfillmentChannel())
{
$response_data[$counter]["Fulfilled_By"] = $qualifiers->getFulfillmentChannel();
}
if($qualifiers->isSetShippingTime())
{
$shippingTime = $qualifiers->getShippingTime();
if($shippingTime->isSetMax())
{
$response_data[$counter]["ShippingTime"] = $shippingTime->getMax();
}
}
}
if($lowestOfferListing->isSetPrice())
{
$price1 = $lowestOfferListing->getPrice();
if($price1->isSetLandedPrice())
{
$landedPrice1 = $price1->getLandedPrice();
if($landedPrice1->isSetAmount())
{
$response_data[$counter]["LandedPrice"] = $landedPrice1->getAmount();
}
}
if($price1->isSetListingPrice())
{
$listingPrice1 = $price1->getListingPrice();
if($listingPrice1->isSetAmount())
{
$response_data[$counter]["ListingPrice"] = $listingPrice1->getAmount();
}
}
if($price1->isSetShipping())
{
$shipping1 = $price1->getShipping();
if($shipping1->isSetAmount())
{
$response_data[$counter]["Shipping"] = $shipping1->getAmount() . "\n";
}
}
}
$counter++;
}
}
}
if($getLowestOfferListingsForSKUResult->isSetError())
{
$error = $getLowestOfferListingsForSKUResult->getError();
if($error->isSetMessage())
{
$response_data = $error->getMessage() . "\n";
}
}
}
return $response_data;
}
catch(MarketplaceWebServiceProducts_Exception $ex)
{
echo("Caught Exception: " . $ex->getMessage() . "\n");
echo("Response Status Code: " . $ex->getStatusCode() . "\n");
echo("Error Code: " . $ex->getErrorCode() . "\n");
echo("Error Type: " . $ex->getErrorType() . "\n");
echo("Request ID: " . $ex->getRequestId() . "\n");
echo("XML: " . $ex->getXML() . "\n");
}
}
答案 1 :(得分:0)
您可以像Keyur一样使用Amazon MWS products API州。它们提供PHP,C#和Java示例代码,并且易于使用。
如果您想要了解当前销售的产品的实时价格变动通知,请订阅AnyOfferChangedNotification
通知。他们也有示例代码。 http://docs.developer.amazonservices.com/en_US/notifications/Notifications_AnyOfferChangedNotification.html
答案 2 :(得分:0)
我现在正在做一些这样的事情,如果它对任何人有帮助,我正在使用广告API,并且发现如果你提出这样的请求:
String requestString = "Service=AWSECommerceService"
+ "&Version=2009-03-31"
+ "&Operation=ItemLookup"
+ "&AssociateTag=some-associate-tag"
+ "&ItemId=" + your-item-id
+ "&ResponseGroup=BrowseNodes,OfferFull,ItemAttributes";
然后你可以查看XPath // detailpageurl,你应该得到你期望的结果。