Last active
January 25, 2016 03:34
-
-
Save kurozumi/c579b5c407bcb39a3acb to your computer and use it in GitHub Desktop.
【Amazon Product Adverstising API】ASINからパッケージ寸法を取得できるクラスの使い方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "vendor/autoload.php"; | |
use ApaiIO\Configuration\GenericConfiguration; | |
use ApaiIO\ResponseTransformer\XmlToSimpleXmlObject; | |
use ApaiIO\Operations\Lookup; | |
use ApaiIO\ApaiIO; | |
use Acme\ItemLookup; | |
$conf = new GenericConfiguration(); | |
$conf | |
->setCountry('com') | |
->setAccessKey(AWS_API_KEY) | |
->setSecretKey(AWS_API_SECRET_KEY) | |
->setAssociateTag(AWS_ASSOCIATE_TAG); | |
$apaiIO = new ApaiIO($conf); | |
$search = new Lookup(); | |
$search->setCategory('DVD'); | |
$search->setActor('Bruce Willis'); | |
$search->setKeywords('Die Hard'); | |
$response = $apaiIO->runOperation($search); | |
$itemLookup = new ItemLookup(simplexml_load_string($response)); | |
if ($itemLookup->isValid()) { | |
foreach ($itemLookup as $item) | |
{ | |
$data[] = [ | |
"asin" => $itemLookup->getAsin(), | |
"weight" => $itemLookup->getWeight(), | |
"width" => $itemLookup->getWidth(), | |
"height" => $itemLookup->getHeight(), | |
"length" => $itemLookup->getLength(), | |
"title" => $itemLookup->getTitle(), | |
"salesrank" => $itemLookup->getSalesRank() | |
]; | |
} | |
if($itemLookup->getError()){ | |
foreach($itemLookup->getError()->Error as $error) | |
echo $error; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment