0

我想开发window phone 8 应用程序。我是 windows phone 8 应用程序的新手。我想确认我可以在 windows phone 8 应用程序中使用亚马逊的产品广告 api 吗?我遇到的问题是我无法像在 Web 应用程序中那样引用IClientMessageInspector接口

  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) { }
}
4

2 回答 2

0

Windows Phone 8 不支持此接口。

这是一个非常简单的界面,因此您可以重新创建它。

于 2013-07-10T09:52:36.703 回答
0

根据亚马逊政策,您不能使用亚马逊产品广告 API 为手机或其他手持设备开发应用程序,请参阅以下链接。 https://affiliate-program.amazon.com/gp/advertising/api/detail/agreement.html

于 2013-07-10T12:11:17.527 回答