我正在努力完成让我的第一部分代码与AWS一起工作的最后一部分 - 我已经做到了这一点,我在VS中附加了Web引用,这有这个
amazon.AWSECommerceService service = new amazon.AWSECommerceService();
// prepare an ItemSearch request
amazon.ItemSearchRequest request = new amazon.ItemSearchRequest();
request.SearchIndex = "DVD";
request.Title = "scream";
request.ResponseGroup = new string[] { "Small" };
amazon.ItemSearch itemSearch = new amazon.ItemSearch();
itemSearch.AssociateTag = "";
itemSearch.Request = new ItemSearchRequest[] { request };
itemSearch.AWSAccessKeyId = ConfigurationManager.AppSettings["AwsAccessKeyId"];
itemSearch.Request = new ItemSearchRequest[] { request };
ItemSearchResponse response = service.ItemSearch(itemSearch);
// write out the results
foreach (var item in response.Items[0].Item)
{
Response.Write(item.ItemAttributes.Title + "<br>");
}
我收到错误
The request must contain the parameter Signature.
我知道你现在必须“签署”请求,但无法弄清楚我会在哪里做这个或如何做?任何帮助非常感谢?
答案 0 :(得分:2)
您必须添加SOAP请求标头,包括您的Amazon访问密钥ID,时间戳以及请求操作的SHA256哈希值和时间戳。要实现这一点,您需要在发送之前访问SOAP消息。我在http://flyingpies.wordpress.com/2009/08/01/17/汇总了一个演练和示例项目。
答案 1 :(得分:1)
记录:
获得此错误的另一个原因是由于其中包含空格的关键字。
示例:
“http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=xxx&AssociateTag=usernetmax-20&Version=2011-08-01&Operation=ItemSearch&ResponseGroup=Medium,Offers& SearchIndex =所有&安培;关键词= <强>婴儿 婴儿车强>&安培; MERCHANTID =所有&安培;条件=所有&安培;可用性=空闲&安培; ItemPage = 1&安培;时间戳= 2012-05-16T02:17:32Z&安培;签名= ye5c2jo99cr3%2BPXVkMyXX8vMhTC21UO4XfHpA21%2BUCs%3D'
应该是:
“http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=xxx&AssociateTag=usernetmax-20&Version=2011-08-01&Operation=ItemSearch&ResponseGroup=Medium,Offers& SearchIndex =所有&安培;关键词= <强>婴儿%20Stroller 强>&安培; MERCHANTID =所有&安培;条件=所有&安培;可用性=空闲&安培; ItemPage = 1&安培;时间戳= 2012-05-16T02:17:32Z&安培;签名= ye5c2jo99cr3% 2BPXVkMyXX8vMhTC21UO4XfHpA21%2BUCs%3D'
PHP解决方案:
$Keywords = str_replace(' ', '%20', $Keywords);
或
$Keywords = urlencode($Keywords);