1

ウェブサイトに商品画像を表示する方法がわかりません。以下をコーディングしました。応答から製品画像だけを抽出するにはどうすればよいですか?

    <?php


  require_once 'lib/AmazonECS.class.php';


 $client = new AmazonECS('AWSApi','AWSSected','DE','Assoicate');

 $response  = $client->category('Photo')->search('Nikon');

  var_dump($response);

   ?>

次の応答が返されます (これらの多く)。一部情報を削除しました。

[8]=>
  object(stdClass)#71 (5) {
    ["ASIN"]=>
    string(10) "B008VO4INW"
    ["ParentASIN"]=>
    string(10) "B0091FA5PA"
    ["DetailPageURL"]=>
    string(217) "http://www.amazon.de/Nikon-Coolpix-L610-Kompaktkamera-Megapixel/dp/B008VO4INW%3FSubscriptionId%3XXX%26tag%3DXXXX%26linkCode%3Dsp1%26camp%3D2025%26creative%3D165953%26creativeASIN%3DB008VO4INW"
    ["ItemLinks"]=>
    object(stdClass)#72 (1) {
      ["ItemLink"]=>
      array(4) {
        [0]=>
        object(stdClass)#73 (2) {
          ["Description"]=>
          string(15) "Add To Wishlist"
          ["URL"]=>
          string(216) "http://www.amazon.de/gp/registry/wishlist/add-item.html%3Fasin.0%3DB008VO4INW%26SubscriptionId%3XXXQ%26tag%3DXXX%26linkCode%3Dsp1%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB008VO4INW"
        }
        [1]=>
        object(stdClass)#74 (2) {
          ["Description"]=>
          string(13) "Tell A Friend"
          ["URL"]=>
          string(181) "http://www.amazon.de/gp/pdp/taf/B008VO4INW%3FSubscriptionId%3XXXFQ%26tag%3DXXX0%26linkCode%3Dsp1%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB008VO4INW"
        }
        [2]=>
        object(stdClass)#75 (2) {
          ["Description"]=>
          string(20) "All Customer Reviews"
          ["URL"]=>
          string(185) "http://www.amazon.de/review/product/B008VO4INW%3FSubscriptionId%3DXXXTFQ%26tag%3DxXXX-20%26linkCode%3Dsp1%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB008VO4INW"
        }
        [3]=>
        object(stdClass)#76 (2) {
          ["Description"]=>
          string(10) "All Offers"
          ["URL"]=>
          string(187) "http://www.amazon.de/gp/offer-listing/B008VO4INW%3FSubscriptionId%3DXXXXQ%26tag%3DXXX0%26linkCode%3Dsp1%26camp%3D2025%26creative%3D12738%26creativeASIN%3DB008VO4INW"
        }
      }
    }
    ["ItemAttributes"]=>
    object(stdClass)#77 (3) {
      ["Manufacturer"]=>
      string(5) "Nikon"
      ["ProductGroup"]=>
      string(11) "Photography"
      ["Title"]=>
      string(95) "Nikon Coolpix L610 Kompaktkamera (16 Megapixel, 14-fach opt. Zoom, 7,6 cm (3 Zoll) Display) rot"
    }
  }


 After incorporate changes below, got this response:

 object(stdClass)#85 (2) {
   ["OperationRequest"]=>
   object(stdClass)#86 (4) {
      ["HTTPHeaders"]=>
    object(stdClass)#87 (1) {
      ["Header"]=>
      object(stdClass)#88 (2) {
       ["Name"]=>
       string(9) "UserAgent"
        ["Value"]=>
        string(26) "PHP-SOAP/5.3.10-1ubuntu3.4"
      }
      }
    ["RequestId"]=>
    string(36) "2af6eed8-4c6e-4211-bdd6-48304336624d"
   ["Arguments"]=>
    object(stdClass)#89 (1) {
     ["Argument"]=>
      object(stdClass)#90 (2) {
        ["Name"]=>
        string(7) "Service"
       ["Value"]=>
        string(19) "AWSECommerceService"
     }
    }
    ["RequestProcessingTime"]=>
    float(0.00219)
   }
  ["Items"]=>
   object(stdClass)#91 (1) {
    ["Request"]=>
    object(stdClass)#92 (3) {
      ["IsValid"]=>
      string(5) "False"
      ["ItemLookupRequest"]=>
      object(stdClass)#93 (3) {
    ["IdType"]=>
    string(4) "ASIN"
    ["ResponseGroup"]=>
    string(6) "Images"
    ["VariationPage"]=>
    string(3) "All"
  }
  ["Errors"]=>
  object(stdClass)#94 (1) {
    ["Error"]=>
    object(stdClass)#95 (2) {
      ["Code"]=>
      string(21) "AWS.MissingParameters"
      ["Message"]=>
      string(80) "Your request is missing required parameters. Required parameters include ItemId."
    }
  }
}

} }

4

1 に答える 1

0

このsearchメソッドは検索結果を提供します。画像を取得するにはもう少し作業が必要です。

  require_once 'lib/AmazonECS.class.php';
  $client = new AmazonECS('AWSApi','AWSSected','DE','Assoicate');
  $search  = $client->category('Photo')->search('Nikon');
  if ($search) {
    $lookup = $client->responseGroup('Images')->lookup($search->ASIN);
    echo '<pre>';
    var_dump($lookup); // will give you the item's object and the image's url
  }
于 2012-12-19T21:47:23.147 に答える