我想開發窗口手機8應用程序。我是窗口手機8應用程序的新手。我想確認一下,我可以在Windows Phone 8應用程序中使用亞馬遜的產品廣告API嗎?我得到的問題是,我不能夠引用IClientMessageInspector接口正如我在Web應用程序中做了亞馬遜產品廣告api在windows phone 8
public class AmazonSigningMessageInspector : IClientMessageInspector
{
private string accessKeyId = "";
private string secretKey = "";
public AmazonSigningMessageInspector(string accessKeyId, string secretKey)
{
this.accessKeyId = accessKeyId;
this.secretKey = secretKey;
}
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
// prepare the data to sign
string operation = Regex.Match(request.Headers.Action, "[^/]+$").ToString();
DateTime now = DateTime.UtcNow;
string timestamp = now.ToString("yyyy-MM-ddTHH:mm:ssZ");
string signMe = operation + timestamp;
byte[] bytesToSign = Encoding.UTF8.GetBytes(signMe);
// sign the data
byte[] secretKeyBytes = Encoding.UTF8.GetBytes(secretKey);
HMAC hmacSha256 = new HMACSHA256(secretKeyBytes);
byte[] hashBytes = hmacSha256.ComputeHash(bytesToSign);
string signature = Convert.ToBase64String(hashBytes);
// add the signature information to the request headers
request.Headers.Add(new AmazonHeader("AWSAccessKeyId", accessKeyId));
request.Headers.Add(new AmazonHeader("Timestamp", timestamp));
request.Headers.Add(new AmazonHeader("Signature", signature));
return null;
}
public void AfterReceiveReply(ref Message reply, object correlationState) { }
}
所以從開始到結束創建windows phone 8 amazon應用程序都不會有問題? – maztt
令人困惑的是,在開始在Visual Studio中使用Windows Phone工作的第一步中,幾乎所有控制檯上的事情都被卡住了。 – maztt
我不能說是否會有其他問題,但如果你只是缺少一個接口,它會很容易創建。 API看起來只是REST接口上的所有XML,所以應該是可能的。 –