背景知识:
【整理】Amazon的AWS(Associates Web Service,新改名为Product Advertising API)
AWS的API使用过程中,发现还是有很多事情需要注意的。
现总结如下:
AWS中的SearchIndex使用注意事项
详见:
一些细节方面的注意事项
现在AWS的API中已经不支持MerchantId了
参见:
Changes to the Product Advertising API
已经不再支持MerchantId了,所以,即使加上参数:
Condition=All ResponseGroup=OfferFull |
也无法再获得对应的MerchantId了:
【已解决】C#中如何通过AWS去获得Merchant的Id和name,即MerchantId和商家名字
通过ResponseGroup=Offers所获得的信息,都是指的是卖家的个数,而不是该产品还剩多少个
比如:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | < Item > < ASIN >B003F4TH6G</ ASIN > < ParentASIN >B00B2R5QPO</ ParentASIN > < OfferSummary > < LowestNewPrice > < FormattedPrice >Too low to display</ FormattedPrice > </ LowestNewPrice > < LowestUsedPrice > < Amount >10000</ Amount > < CurrencyCode >USD</ CurrencyCode > < FormattedPrice >$100.00</ FormattedPrice > </ LowestUsedPrice > < TotalNew >26</ TotalNew > < TotalUsed >1</ TotalUsed > < TotalCollectible >0</ TotalCollectible > < TotalRefurbished >0</ TotalRefurbished > </ OfferSummary > < Offers > < TotalOffers >2</ TotalOffers > < TotalOfferPages >1</ TotalOfferPages > |
其中的TotalNew,TotalUsed,TotalCollectible,TotalRefurbished,
都只是针对卖家(Offer)而言的,不是针对,产品(Product或Item)而言的。
不要像我之前一样搞混了。。
通过AWS获得的产品的LargeImage只有一个
本来用浏览器查看某个产品,一般都是有5张图片的,
有的少的有2个,多个有7个或更多。
但是后来用AWS的API中的ResponseGroup=Images得到的却只有1张图片。
即:
【已搞懂】C#中通过AWS获得某产品的ResponseGroup=Images的所有的LargeImage
所以,只能:
通过AWS的ResponseGroup=Images去获得,单个的,Primary的LargeImage
然后再去通过:
http://www.amazon.com/gp/customer-media/product-gallery/ASIN
比如:
http://www.amazon.com/gp/customer-media/product-gallery/B003C9HUDQ
去访问页面,获得custom的所有的图片,包括LargeImage
注意在传入BrowseNodeId的时候,不要有多余的空格
之前不小心,把BrowseNodeId为字符串"2617941011",误写成了"2617941011 "
即,在末尾处,不小心加了个多余的空格,结果导致返回出错:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | < BrowseNodes > < Request > < IsValid >True</ IsValid > < BrowseNodeLookupRequest > < BrowseNodeId >2617941011 </ BrowseNodeId > < ResponseGroup >BrowseNodeInfo</ ResponseGroup > </ BrowseNodeLookupRequest > < Errors > < Error > < Code >AWS.InvalidParameterValue</ Code > < Message >2617941011 is not a valid value for BrowseNodeId. Please change this value and retry your request.</ Message > </ Error > </ Errors > </ Request > |
注意到:
<BrowseNodeId>2617941011 </BrowseNodeId> |
中间是"2617941011 "而不是"2617941011"
而后来去掉多余的空格,就返回正常的结果了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | < BrowseNodeLookupResponse > < OperationRequest > < HTTPHeaders > < Header Name = "UserAgent" Value = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E" /> </ HTTPHeaders > < RequestId >dbb4ed8c-231d-49a6-933a-a235ca36a769</ RequestId > < Arguments > < Argument Name = "Operation" Value = "BrowseNodeLookup" /> < Argument Name = "Service" Value = "AWSECommerceService" /> < Argument Name = "AssociateTag" Value = "xxx" /> < Argument Name = "Version" Value = "2011-08-01" /> < Argument Name = "Signature" Value = "GKuxNEc5WLE2JN13hvoVkg4mnmzBJM5+BR0WXBQkhg0=" /> < Argument Name = "BrowseNodeId" Value = "2617941011" /> < Argument Name = "AWSAccessKeyId" Value = "xxx" /> < Argument Name = "Timestamp" Value = "2013-06-20T06:09:43Z" /> < Argument Name = "ResponseGroup" Value = "BrowseNodeInfo" /> </ Arguments > < RequestProcessingTime >0.041807</ RequestProcessingTime > </ OperationRequest > < BrowseNodes > < Request > < IsValid >True</ IsValid > < BrowseNodeLookupRequest > < BrowseNodeId >2617941011</ BrowseNodeId > < ResponseGroup >BrowseNodeInfo</ ResponseGroup > </ BrowseNodeLookupRequest > </ Request > < BrowseNode > < BrowseNodeId >2617941011</ BrowseNodeId > < Name >Arts, Crafts & Sewing</ Name > < Children > < BrowseNode > < BrowseNodeId >2617942011</ BrowseNodeId > < Name >Categories</ Name > < IsCategoryRoot >1</ IsCategoryRoot > </ BrowseNode > < BrowseNode > < BrowseNodeId >2617943011</ BrowseNodeId > < Name >Self Service</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >2623321011</ BrowseNodeId > < Name >Featured Categories</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >3026791011</ BrowseNodeId > < Name >Specialty Stores</ Name > </ BrowseNode > </ Children > </ BrowseNode > </ BrowseNodes > </ BrowseNodeLookupResponse > |
心得是:
BrowseNodeId必须是纯数字,不能有多余的其他值。
总之不要再犯这类低级错误。。。
Browse Node IDs中的PetSupplies=1063498不是真正的根节点分类
对于:
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeIDs.html
中列出来的,所有的Browse Node IDs的名字,比如:Apparel,Appliances,。。。
都应该是,root category,最顶端的,根分类,才对。
然后其下有各种sub category。
但是,对于PetSupplies,对于US的话BrowseNodeId是1063498,
但是通过BrowseNodeLookup得到的BrowseNodeInfo的返回值却是:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | < BrowseNodeLookupResponse > < OperationRequest > < HTTPHeaders > < Header Name = "UserAgent" Value = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E" /> </ HTTPHeaders > < RequestId >a7ed7512-7adf-49d0-8911-33668d867aa7</ RequestId > < Arguments > < Argument Name = "Operation" Value = "BrowseNodeLookup" /> < Argument Name = "Service" Value = "AWSECommerceService" /> < Argument Name = "BrowseNodeId" Value = "1063498" /> < Argument Name = "AWSAccessKeyId" Value = "xxx" /> < Argument Name = "Timestamp" Value = "2013-07-04T07:45:46Z" /> < Argument Name = "Signature" Value = "l05k0j8g5safWbF7XufhaIrJmG6/IJPM6JBuJMr6h74=" /> < Argument Name = "ResponseGroup" Value = "BrowseNodeInfo" /> < Argument Name = "AssociateTag" Value = "xxx" /> < Argument Name = "Version" Value = "2011-08-01" /> </ Arguments > < RequestProcessingTime >0.002381</ RequestProcessingTime > </ OperationRequest > < BrowseNodes > < Request > < IsValid >True</ IsValid > < BrowseNodeLookupRequest > < BrowseNodeId >1063498</ BrowseNodeId > < ResponseGroup >BrowseNodeInfo</ ResponseGroup > </ BrowseNodeLookupRequest > </ Request > < BrowseNode > < BrowseNodeId >1063498</ BrowseNodeId > < Name >Categories</ Name > < IsCategoryRoot >1</ IsCategoryRoot > < Children > < BrowseNode > < BrowseNodeId >3206325011</ BrowseNodeId > < Name >Kids' Home Store</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >284507</ BrowseNodeId > < Name >Kitchen & Dining</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >1063252</ BrowseNodeId > < Name >Bedding</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >1063236</ BrowseNodeId > < Name >Bath</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >1063306</ BrowseNodeId > < Name >Furniture</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >1063278</ BrowseNodeId > < Name >Home Décor</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >3736081</ BrowseNodeId > < Name >Artwork</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >13679381</ BrowseNodeId > < Name >Seasonal Décor</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >3206324011</ BrowseNodeId > < Name >Heating, Cooling & Air Quality</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >510240</ BrowseNodeId > < Name >Irons & Steamers</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >510106</ BrowseNodeId > < Name >Vacuums & Floor Care</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >3610841</ BrowseNodeId > < Name >Storage & Organization</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >10802561</ BrowseNodeId > < Name >Cleaning Supplies</ Name > </ BrowseNode > </ Children > < Ancestors > < BrowseNode > < BrowseNodeId >1055398</ BrowseNodeId > < Name >Home & Kitchen</ Name > </ BrowseNode > </ Ancestors > </ BrowseNode > </ BrowseNodes > </ BrowseNodeLookupResponse > |
即,1063498的这个BrowseNodeId,其实是root category为BrowseNodeId=1055398的Home & Kitchen的sub category。
即,1063498本身不是root category。
由此带来的问题是:
本来,正常的逻辑是去按照:
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeIDs.html
去列出来,所有的root category,结果当对于BrowseNodeId=1063498的PetSupplies,却由于其不是root category,而导致整个逻辑关系,都不对了。
导致对于1063498去BrowseNodeLookup得到的BrowseNodeInfo,得到所有的sub category的BrowseNodeId,但是其内容看起来,却明显是Home & Kitchen的sub category,而不是PetSupplies的sub category。
然后,又专门去看了看对于1055398这个真正的根目录分类的子节点是哪些,结果是:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | < BrowseNodeLookupResponse > < OperationRequest > < HTTPHeaders > < Header Name = "UserAgent" Value = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E" /> </ HTTPHeaders > < RequestId >a5605c52-69c2-49ce-bcf7-53651b674bc3</ RequestId > < Arguments > < Argument Name = "Operation" Value = "BrowseNodeLookup" /> < Argument Name = "Service" Value = "AWSECommerceService" /> < Argument Name = "Signature" Value = "oluzi5p/j0wNtpprg/B/e9i4mG+zVL1LPqY+g6DbrzU=" /> < Argument Name = "AssociateTag" Value = "xxx" /> < Argument Name = "Version" Value = "2011-08-01" /> < Argument Name = "BrowseNodeId" Value = "1055398" /> < Argument Name = "AWSAccessKeyId" Value = "xxx" /> < Argument Name = "Timestamp" Value = "2013-07-04T08:01:09Z" /> < Argument Name = "ResponseGroup" Value = "BrowseNodeInfo" /> </ Arguments > < RequestProcessingTime >0.001986</ RequestProcessingTime > </ OperationRequest > < BrowseNodes > < Request > < IsValid >True</ IsValid > < BrowseNodeLookupRequest > < BrowseNodeId >1055398</ BrowseNodeId > < ResponseGroup >BrowseNodeInfo</ ResponseGroup > </ BrowseNodeLookupRequest > </ Request > < BrowseNode > < BrowseNodeId >1055398</ BrowseNodeId > < Name >Home & Kitchen</ Name > < Children > < BrowseNode > < BrowseNodeId >1063498</ BrowseNodeId > < Name >Categories</ Name > < IsCategoryRoot >1</ IsCategoryRoot > </ BrowseNode > < BrowseNode > < BrowseNodeId >258599011</ BrowseNodeId > < Name >Home & Kitchen Filtered Stores</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >13900811</ BrowseNodeId > < Name >Home & Kitchen Features</ Name > </ BrowseNode > < BrowseNode > < BrowseNodeId >13900821</ BrowseNodeId > < Name >Kitchen & Dining Features</ Name > </ BrowseNode > </ Children > </ BrowseNode > </ BrowseNodes > </ BrowseNodeLookupResponse > |
即,对于1055398=Home & Kitchen,子节点包括:
Categories
Home & Kitchen Filtered Stores
Home & Kitchen Features
Kitchen & Dining Features
对此,后来也找到了对应的,有人整理出来的上述的内容了:
所以,看来很明显是:
amazon服务器那边,对于PetSupplies=1063498早就变成了真正的根目录节点:Home & Kitchen=1055398
但是此处的文档这里:
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeIDs.html
却没及时更新而已。
后来,又经过折腾发现,如果针对Home & Kitchen去做search的话,即,用任何一个子节点,比如678522011,都会出问题:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | < Request > < IsValid >False</ IsValid > < ItemSearchRequest > < Availability >Available</ Availability > < BrowseNode >678522011</ BrowseNode > < Condition >All</ Condition > < ItemPage >1</ ItemPage > < ResponseGroup >ItemIds</ ResponseGroup > < SearchIndex >HomeAndKitchen</ SearchIndex > </ ItemSearchRequest > < Errors > < Error > < Code >AWS.InvalidEnumeratedParameter</ Code > < Message >The value you specified for SearchIndex is invalid. Valid values include [ 'All','Apparel','Appliances','ArtsAndCrafts','Automotive','Baby','Beauty','Blended','Books','Classical','Collectibles','DVD','DigitalMusic','Electronics','GiftCards','GourmetFood','Grocery','HealthPersonalCare','HomeGarden','Industrial','Jewelry','KindleStore','Kitchen','LawnAndGarden','Marketplace','MP3Downloads','Magazines',,'Miscellaneous','Music','MusicTracks','MusicalInstruments','MobileApps','OfficeProducts','OutdoorLiving','PCHardware','PetSupplies','Photo','Shoes','Software','SportingGoods','Tools','Toys','UnboxVideo','VHS','Video','VideoGames','Watches','Wireless','WirelessAccessories' ].</ Message > </ Error > </ Errors > </ Request > |
而经过尝试发现, 其实,此处的SearchIndex不论用:
HomeAndKitchen
Home & Kitchen
都会出错。
然后最后换为:
HomeGarden
即可。
即:
之前
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeIDs.html
中的HomeGarden=285080,已经失效,实际上变成了:
HomeGarden=1055398
(但是网页浏览的时候,比如
http://www.amazon.com/Best-Sellers/zgbs
中看到的是: Home & Kitchen)
然后,其下的任何一个子节点,sub category,去做BrowseNodeLookup
的时候,需要指定对应的SearchIndex为HomeGarden
然后才可以正常返回内容,才不会出现上面的那个InvalidEnumeratedParameter的。
其他更多内容,参见:
【注意事项】AWS中的Toys的BrowseNodeId=493964不是真正的根分类
【整理】AWS中的SearchIndex不再支持LawnGarden,已改名为LawnAndGarden
转载请注明:在路上 » 【整理】AWS的API使用注意事项