Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. require 'vendor/autoload.php';
  2.  
  3. use ApaiIO\Configuration\GenericConfiguration;
  4. use ApaiIO\Operations\Lookup;
  5. use ApaiIO\ApaiIO;
  6.  
  7. $asin = "ASIN";
  8.  
  9. $conf = new GenericConfiguration();
  10.  
  11. try {
  12. $conf
  13. ->setCountry("co.jp")
  14. ->setAccessKey(AWS_API_KEY)
  15. ->setSecretKey(AWS_API_SECRET_KEY)
  16. ->setAssociateTag(AWS_ASSOCIATE_TAG);
  17.  
  18. $apaiIO = new ApaiIO($conf);
  19.  
  20. $lookup = new Lookup();
  21. $lookup->setResponseGroup(array('OfferSummary'));
  22. $lookup->setItemId($asin);
  23.  
  24. $formattedResponse = $apaiIO->runOperation($lookup);
  25. $xml = simplexml_load_string($formattedResponse);
  26.  
  27. if (isset($xml->Items->Item->OfferSummary->LowestNewPrice->Amount))
  28. {
  29. echo "<p>{$xml->Items->Item->OfferSummary->LowestNewPrice->Amount}</p>";
  30. } else
  31. {
  32. echo "<p>新品の最安値がありませんでした。</p>";
  33. }
  34. } catch (\Exception $e) {
  35. //echo $e->getMessage();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement