samedi 5 septembre 2015

Using AWS to grab images for MY data

I have a site which has UPC, Item Names and unit cost What I would like is to use AWS to grab image for corresponding UPC if available and display it next to item name. I currently have a search that works with only one item UPC and grabs information on that item with AWS.

I have a database with all the items in it.

What would be the best possible way to display all the information and Images for items if available?

  $request = aws_signed_request('com', array(
    'Operation' => 'ItemLookup',
    'IdType' => 'UPC',
    'ItemId' => '082666711001',
    'SearchIndex' => 'All',
    'ResponseGroup' => 'Large'), $public_key, $private_key, $associate_tag);
   // do request (you could also use curl etc.)
  $response = @file_get_contents($request);
 if ($response === FALSE) {
     echo "Request failed.\n";
  } else {
// parse XML
$pxml = simplexml_load_string($response);
if ($pxml === FALSE) {
    echo "Response could not be parsed.\n";
} else {
    if (isset($pxml->Items->Item->ItemAttributes->Title)) {
        echo $pxml->Items->Item->ItemAttributes->Title, "\n";
    }
    echo "<br>";
    if (isset($pxml->Items->Item->DetailPageURL)) {
     //   echo $pxml->Items->Item->DetailPageURL, "\n";
        }

        echo "<br>";
        if (isset($pxml->Items->Item->MediumImage->URL)) {
        //echo $pxml->Items->Item->MediumImage->URL, "\n";


    }
}
   }


  ?>
  <img src="<?php echo $pxml->Items->Item->MediumImage->URL, "\n"; ?>">

Thats my current code for the single item lookup.




Aucun commentaire:

Enregistrer un commentaire