define("ASSOCIATE_ID", "アソシエイトID"); define("SUBSCRIPTION_ID", "サブスクリプションID"); define("INPUT_BASE", "UTF-8"); define("ECS4_VERSION", "2007-01-15");
define("WEBSERV_URL", "アマゾンウェッブサービスのURL");
class Ecs4Personal { var $Client; var $Proxy; var $SubscriptionId = SUBSCRIPTION_ID; var $AssociateTag = ASSOCIATE_ID; var $Version = ECS4_VERSION;
function Ecs4Personal() { $soapclient = new soapclientx(WEBSERV_URL, 'wsdl'); $this->Client = $soapclient; $proxy = $soapclient->getProxy(); $this->Proxy = $proxy; $soapclient->setDebugLevel(1); }
function SetAssociateID($aid) { $AssociateTag = $aid; } } class EcsSearchWord { var $SubscriptionId; var $AssociateTag; var $params; var $SortItem = array( 'Video' => array('Sort' => '-orig-rel-date' ,'BrowseNode' => '562002'), 'DVD' => array('Sort' => '-orig-rel-date' ,'BrowseNode' => '562002'), 'Books' => array('Sort' => 'daterank' ,'BrowseNode' => '465610'), 'Electronics' => array('Sort' => '-release-date' ,'BrowseNode' => '3210991'), 'VideoGames' => array('Sort' => 'salesrank' ,'BrowseNode' => '637872'), 'Toys' => array('Sort' => '-release-date' ,'BrowseNode' => '13299551'), );
function EcsSearchWord($SubscriptionId, $AssociateTag) { if($SubscriptionId != null){ $this->SubscriptionId = $SubscriptionId; } else { $this->SubscriptionId = SUBSCRIPTION_ID; }
if($AssociateTag != null){ $this->AssociateTag = $AssociateTag; } else { $this->AssociateTag = ASSOCIATE_ID; } }
function CreateItemSearch($SearchIndex,$Keywords,$Page){
$this->Request['SearchIndex'] = $SearchIndex;
if(($Keywords != null) && ($Keywords != '')){ $this->Request['Keywords'] = $Keywords; } if($SortItem[$SearchIndex] != null){ $this->Request['Sort'] = $SortItem[$SearchIndex]['Sort']; $this->Request['BrowseNode'] = $SortItem[$SearchIndex]['BrowseNode']; }
if($Keywords == null){ $this->Request['Sort'] = 'salesrank'; }
$this->Request['Conditon'] = 'New'; $this->Request['Version'] = ECS4_VERSION; $this->Request['MerchantId'] = 'Amazon'; $this->Request['ResponseGroup'] = array('Large', 'OfferFull','Variations','ItemAttributes', 'Tracks','Accessories','EditorialReview','Images','Reviews'); $this->Request['ItemPage'] = $Page;
$params = array('SubscriptionId' => $this->SubscriptionId, 'AssociateTag' => $this->AssociateTag, 'Request' => $this->Request);
return $params; }
function CreateSimilarityLookup($ASIN,$Page){ $this->Request['ItemId'] = $ASIN; $this->Request['Sort'] = 'daterank'; $this->Request['Conditon'] = 'New'; $this->Request['Version'] = ECS4_VERSION; $this->Request['MerchantId'] = 'Amazon'; $this->Request['ResponseGroup'] = array('Large', 'OfferFull','Variations','ItemAttributes', 'Tracks','Accessories','EditorialReview','Images','Reviews'); $this->Request['ItemPage'] = $Page;
$params = array('SubscriptionId' => $this->SubscriptionId, 'AssociateTag' => $this->AssociateTag, 'Request' => $this->Request);
return $params; } } class Ecs4Item { var $ASIN; var $Image; var $Author; var $Manufacturer; var $AverageRating; var $ReleaseDate; var $Availability; var $Price; function Ecs4Item(){ } }
class Ecs4 extends Ecs4Personal { var $result; var $TotalResult; var $TotalPage;
function Ecs4() { parent::Ecs4Personal(); }
function ItemSearchKeyword($SearchIndex,$Keywords,$Page) { $word = mb_convert_encoding($Keywords,"UTF-8",INPUT_BASE); $querykey = rawurlencode($word);
$word = new EcsSearchWord($this->SubscriptionId, $this->AssociateTag);
$proxy = $this->Proxy; $param = $word->CreateItemSearch($SearchIndex,$Keywords,$Page);
$this->result = $proxy->ItemSearch($param);
$this->TotalResult = $this->result['Items']['TotalResults']; $this->TotalPage = $this->result['Items']['TotalPages'];
return $this->result; }
function SimilarityLookup($ASIN,$Page) { $word = new EcsSearchWord($this->SubscriptionId, $this->AssociateTag);
$proxy = $this->Proxy; $param = $word->CreateSimilarityLookup($ASIN,$Page);
$this->result = $proxy->SimilarityLookup($param);
$this->TotalResult = $this->result['Items']['TotalResults']; $this->TotalPage = $this->result['Items']['TotalPages'];
return $this->result; } }
|