doushen8391 2012-12-19 20:48
浏览 106
已采纳

亚马逊产品广告API PHP显示图像

I'm confused how to display product image on my website. I've coded the following. How do I extract just the product image from response?

    <?php


  require_once 'lib/AmazonECS.class.php';


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

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

  var_dump($response);

   ?>

I get the following response (many of these). I've removed some info.

[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."
    }
  }
}

} }

  • 写回答

1条回答 默认 最新

  • duan0708676887 2012-12-19 21:47
    关注

    The search method gives you search results, you need to do a bit more to get an image.

      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
      }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集