【问题标题】:WinRT and missing Web API models for Amazon API access用于 Amazon API 访问的 WinRT 和缺少的 Web API 模型
【发布时间】:2014-04-30 08:36:58
【问题描述】:

我正在将示例从下面的链接移植到 Windows 8 Metro 风格的应用程序

http://aws.amazon.com/code/Product-Advertising-API/2480

看起来 Web 模型中的许多功能在 WinRT 中被删除(或移动)了:

HttpUtility.UrlEncode
HttpUtility.UrlDecode
HMAC / HMACSHA256 

仅举几例,我想知道是否有人可以帮助在 WInRT 上寻找替代方案?我上网查了一下,了解的很少。

【问题讨论】:

标签: amazon windows-8 microsoft-metro windows-runtime


【解决方案1】:

这里有 URLDecode 的源代码,看起来 Uri.EscapeDataString 可以用于 Encode。

http://www.koders.com/csharp/fid1A50096D8FA38302680B0EEDAC5B1CE1AEA855D0.aspx?s=%22Lawrence+Pit%22

把源代码复制过来,把GetChars函数改成这个

    static char [] GetChars (MemoryStream b, Encoding e)
    {
        return e.GetChars (b.ToArray(), 0, (int) b.Length);
    }

我必须使用此处的代码 sn-p 来正确散列加密字符串 http://channel9.msdn.com/Forums/TechOff/Porting-to-WinRT/4df7586e1ef5400682eda00f0143b610

【讨论】:

    【解决方案2】:

    改用WebUtility 类中的方法:

    System.Net.WebUtility.UrlEncode(string);
    System.Net.WebUtility.UrlDecode(string);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-08
      • 2018-12-27
      • 1970-01-01
      • 2011-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多