【问题标题】:Amazon (AWS) - The request must contain the parameter SignatureAmazon (AWS) - 请求必须包含参数 Signature
【发布时间】:2010-05-29 13:04:37
【问题描述】:

我正在为让我的第一段代码与 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.

我知道您现在必须“签署”请求,但不知道“在哪里”我会这样做或如何做?有什么帮助吗?

【问题讨论】:

  • leen3o 你的代码运行了吗?我有同样的问题。你能帮帮我吗??

标签: c# amazon-web-services soap amazon-product-api


【解决方案1】:

您必须向 SOAP 请求标头添加您的 Amazon 访问密钥 ID、时间戳以及请求操作的 SHA256 哈希和时间戳。为此,您需要在 SOAP 消息即将发送之前访问它。我在http://flyingpies.wordpress.com/2009/08/01/17/ 整理了一个演练和一个示例项目。

【讨论】:

  • 嗨 - 我在发布这篇文章之前遵循了你的教程,但无法让它在我的 Web 应用程序中工作。每次它都无法理解 AWSECommerceServicePortTypeClient 是什么?我最终设法从 Amazon 获得了一些示例代码 - 但我必须安装 Microsoft WSE 3.0 并删除我的网络参考:S 血腥疯狂的工作量才能让一些东西变得简单!!!
【解决方案2】:

记录在案:

出现此错误的另一个原因是其中包含空格的关键字。

例子:

'http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=xxx&AssociateTag=usernetmax-20&Version=2011-08-01&Operation=ItemSearch&ResponseGroup=Medium,Offers&SearchIndex=All&Keywords=宝贝 婴儿车&MerchantId=All&Condition=All&Availability=Available&ItemPage=1&Timestamp=2012-05-16T02:17:32Z&Signature=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=All&Keywords=Baby%20Stroller&MerchantId=All&Condition=All&Availability=Available&ItemPage=1&Timestamp=2012-05-16T02:17:32Z&Signature=ye5c2jo99cr3%2BPXVkMyXX8vMhTC21UO4XfHpA21%2BUCs%3D'

PHP解决方案:

$Keywords = str_replace(' ', '%20', $Keywords);

$Keywords = urlencode($Keywords);

【讨论】:

    猜你喜欢
    • 2021-11-22
    • 1970-01-01
    • 1970-01-01
    • 2021-08-04
    • 2021-10-20
    • 2020-12-27
    • 1970-01-01
    • 1970-01-01
    • 2018-09-05
    相关资源
    最近更新 更多