亚马逊商品广告API:获取产品详细信息的URL从ASIN [英] Amazon Product Advertising API: Get Product Detail URL from ASIN
问题描述
我使用的是 PHP SOAP库的连接亚马逊和检索ASINs产品封面。这一点我已经完成,但根据<一个href="https://affiliate-program.amazon.com/gp/advertising/api/detail/agreement.html?ie=UTF8&pf_rd_t=501&ref_=amb_link_83952631_8&pf_rd_m=ATVPDKIKX0DER&pf_rd_p=&pf_rd_s=assoc-center-1&pf_rd_r=&pf_rd_i=assoc-api-detail-0"相对=nofollow>协议(至少据我可以告诉; IANAL),任何信息,我从API获取必须链接到其各自的产品详细信息页面亚马逊零售网站上。我已经通过文档我的,但对于生活浏览我想不通,我需要什么样的方法等的使用,短期手动构造URL(这是潜在的不稳定)的。任何见解?
I am using the PHP Soap Library to connect to Amazon and retrieve product cover art from ASINs. That much I've accomplished, but according to the Agreement (at least as far as I can tell; IANAL), any info I get from the API must be linked to its respective Product Detail Page on the Amazon retail site. I've browsed through the docs, but for the life of me I can not figure out what method, etc. I need to use, short of constructing the URL manually (which is potentially unstable). Any insight?
推荐答案
想通了。这是code我最终使用:
Figured it out. This is the code I ended up using:
<?php
class AmazonMusicSearch extends AmazonECS {
protected $asin;
protected $detailPageUrl;
protected $ecs;
function __get($name) {
return $this->$name;
}
function __construct() {
$this->ecs = new parent(AZ_APP_ID, AZ_APP_SECRET, 'com', AZ_ASSOCIATE_TAG);
}
function searchByAsin($asin) {
$search = $this->ecs->responseGroup('Small')->category('Music')->search($asin);
$this->asin = $asin;
if(isset($search['Items']['Item']['DetailPageURL'])) {
$this->detailPageUrl = $search['Items']['Item']['DetailPageURL'];
} elseif(isset($search['Items']['Item'][0]['DetailPageURL'])) {
$this->detailPageUrl = $search['Items']['Item'][0]['DetailPageURL'];
} else {
return false;
}
return $this;
}
function detailPageFromAsin($asin) {
return $this->searchByAsin($asin)->detailPageUrl;
}
}
?>
这篇关于亚马逊商品广告API:获取产品详细信息的URL从ASIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!