Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinRT and missing Web API models for Amazon API access

I was working with porting the sample from the link below to a Windows 8 Metro styled app

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

Looks like many features from the web model are removed (or moved) in WinRT:

HttpUtility.UrlEncode
HttpUtility.UrlDecode
HMAC / HMACSHA256 

to name a few, I was wondering if anyone could help with finding alternatives to these on WInRT? I looked online and there's very little insight.

like image 265
Jay Kannan Avatar asked Apr 04 '12 14:04

Jay Kannan


2 Answers

Use methods from the WebUtility class instead:

System.Net.WebUtility.UrlEncode(string);
System.Net.WebUtility.UrlDecode(string);
like image 34
Roman Boiko Avatar answered Oct 11 '22 07:10

Roman Boiko


Theres source code for URLDecode here, and looks like Uri.EscapeDataString can be used for Encode.

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

copy the source code over, change the GetChars function to this

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

I had to use the code snippet from here to properly hash encrypt the string http://channel9.msdn.com/Forums/TechOff/Porting-to-WinRT/4df7586e1ef5400682eda00f0143b610

like image 173
Jay Kannan Avatar answered Oct 11 '22 06:10

Jay Kannan