Esempio n. 1
0
        static void Main(string[] args)
        {
            //Authentication
            var authentication = new AmazonAuthentication();

            authentication.AccessKey = "amazon access key here";
            authentication.SecretKey = "amazon secret key here";

            //Search critera and result
            var wrapper         = new AmazonWrapper(authentication, AmazonEndpoint.US, "amazon associate tag here");
            var searchOperation = wrapper.ItemSearchOperation("canon eos", AmazonSearchIndex.Electronics);

            searchOperation.MaxPrice(200000); //2000 USD
            var xmlResponse = wrapper.Request(searchOperation);
            var result      = XmlHelper.ParseXml <ItemSearchResponse>(xmlResponse.Content);

            //Create cart and add items to it
            var items = new List <AmazonCartItem>();

            items.Add(new AmazonCartItem("item code here"));
            var cart = wrapper.CartCreate(items);

            //Debuging

            /*wrapper.XmlReceived += (xml) => { System.Diagnostics.Debug.WriteLine(xml); };
             * wrapper.ErrorReceived += (errorResonse) => { System.Diagnostics.Debug.WriteLine(errorResonse.Error.Message); };
             * var errors = wrapper.Lookup(new string[] { "item code here" });*/
        }
Esempio n. 2
0
        public ActionResult AddCart(string asin)
        {
            var cartId = string.Empty;
            var hmac   = string.Empty;

            var authentication = this.GetConfig();
            var wrapper        = new AmazonWrapper(authentication, this._amazonEndpoint, this._associateTag);

            AmazonCartItem item;

            if (Session["cartId"] == null)
            {
                item = new AmazonCartItem(asin);

                var cardCreateResponse = wrapper.CartCreate(new List <AmazonCartItem> {
                    item
                });

                Session["cartId"] = cardCreateResponse.Cart.CartId;
                Session["hmac"]   = cardCreateResponse.Cart.HMAC;

                return(Json(new { Successful = true, cardCreateResponse.Cart.CartId }, JsonRequestBehavior.AllowGet));
            }

            cartId = Session["cartId"] as string;
            hmac   = Session["hmac"] as string;

            item = new AmazonCartItem(asin);
            var cardAddResponse = wrapper.CartAdd(item, cartId, hmac);

            return(Json(new { Successful = true, cardAddResponse.Cart.CartId }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public static CartCreateResponse CreateCart(string store, string asin_isbn)
        {
            var            authentication = GetAuth();
            AmazonEndpoint endpoint       = GetEndpoint(store);
            var            items          = new List <AmazonCartItem> {
                new AmazonCartItem(asin_isbn)
            };
            var wrapper = new AmazonWrapper(authentication, endpoint, AssociateTag(store));

            wrapper.XmlReceived   += (xml) => { System.Diagnostics.Debug.WriteLine(xml); };
            wrapper.ErrorReceived += (errorResonse) => { System.Diagnostics.Debug.WriteLine(errorResonse.Error.Message); };
            return(wrapper.CartCreate(items));
        }
        static void CreateCart1(AmazonAuthentication authentication)
        {
            Console.WriteLine("CreateCart1");
            Console.WriteLine("------------------------------------------");

            var items = new List <AmazonCartItem>();

            items.Add(new AmazonCartItem("B00MH4QM1S"));
            items.Add(new AmazonCartItem("B01EUHFAC6"));

            var wrapper = new AmazonWrapper(authentication, AmazonEndpoint.DE);
            var result  = wrapper.CartCreate(items);

            Console.WriteLine("------------------------------------------");
        }