Amazon Product API

by George Obregon

HTML

<div id="this"></div>
    <div class="formHide">
        <textarea type="text" name="amadeusINPUT" id="ghreclocator" class2="searchfield" placeholder="  http://webservices.amazon.com/onca/xml?AWSAccessKeyId=' + AccessKeyId + '&AssociateTag=' + associateTag + '&IdType=' + IdType
        + '&ItemId=' + itemId + '&Operation=ItemLookup&ResponseGroup=Images%2CItemAttributes%2COffers&Service=AWSECommerceService&Timestamp='
        + mytimestamp + '&Signature=' + mysig"></textarea>

        <form name="PriceCalc" id="PriceCalc" action="">
            <div class="searchbox" width="auto" max-width="879px" border="0">
            </div>
            <p align="center">
                <input type="button" onclick="testdis()" value="GET DIMENSIONS!"></input>


                <!-- Translate Plugin -->
                <div id="google_translate_element"></div>
                <script type="text/javascript">
                    function googleTranslateElementInit() {
                        new google.translate.TranslateElement({ pageLanguage: 'en', includedLanguages: 'es', layout: google.translate.TranslateElement.FloatPosition.TOP_RIGHT }, 'google_translate_element');
                    }
                </script>
                <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>




    </div>
    </form>

CSS

.bottomPart {
            display: inline-flex;
        }

        .banner img {
            width: 100%;
        }

        .AB {
            display: inline-flex;
            text-align: center;
            font-weight: bold;
            color: #000000;
            padding: 2px;
            font-size: small;
            font-family: Gotham-Bold;
            border-color: #000;
            border-width: 2px;

        }

        .segTitle {
            display: inline-flex;
            text-align: center;
            font-weight: bold;
            color: #000000;
            padding: 2px;
            font-size: small;
            font-family: Gotham-Bold;
            border-color: #000;
            border-width: 2px;
        }

        .baggageTitle {
            color: #239422;
            font-size: small;
        }

        .baggageRestriction {
            font-size: xx-small;
            color: #A2A9B3;
        }

        .baggage {
            display: inline-flex;
            text-align: center;
            font-weight: bold;
            color: #000000;
            padding: 2px;
            font-size: small;
            font-family: Gotham-Bold;
            border-color: #000;
            border-width: 2px;
        }

        body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            background-color: #FAFAFA;
            /*  font: 12pt "Tahoma"; */
        }

        textarea {
            min-width: 40%;
            min-height: 200px;
        }

        * {
            box-sizing: border-box;
            -moz-box-sizing: border-box;
        }

        .introSEG {
            text-align: center;
            font-weight: bold;
            color: #2181b7;
            padding: 2px;
            font-size: large;
            font-family: Gotham-Bold;
            display: inline-block;
        }

        .nameonP {
            text-align: left;
            font-weight: bold;
            Fcolor: #2181b7;
...

JavaScript

var AccessKeyId = 'AKIAJBBUJIPOFZHNFWLQ';
        var associateTag = 'somnis-20';
        var IdType = 'ASIN';
         var itemId = 'B071CV8CG2'
        // [YYYY-MM-DDThh:mm:ssZ]
        var mytimestamp = '2018-06-01T18%3A38%3A47.000Z';
        var mysig = 'TYP2YMFWN4msv0vpQkUz5IchJF%2F8jDwM9%2B4NzdvM%2Bfg%3D';

        var xmlurl = 'http://webservices.amazon.com/onca/xml?AWSAccessKeyId=' + AccessKeyId + '&AssociateTag=' + associateTag + '&IdType=' + IdType + '&ItemId=' + itemId + '&Operation=ItemLookup&ResponseGroup=Images%2CItemAttributes%2COffers&Service=AWSECommerceService&Timestamp=' + mytimestamp + '&Signature=' + mysig;


        function testdis() {

            var myData = {};
            // Get input box as string
            var inputTextarea = document.getElementsByName("amadeusINPUT")[0].value;

                        // If no input than use the default
            // if (!inputTextarea) {
            //     inputTextarea = "http://www.amazon.com/dp/B071CV8CG2";
            // }


            // Clean up Amazon URL entry to extract ASIN as idType
            //(https://stackoverflow.com/questions/1764605/scrape-asin-from-amazon-url-using-javascript)
            // Regex 1
            var regex1 = RegExp("http://www.amazon.com/([\\w-]+/)?(dp|gp/product)/(\\w+/)?(\\w{10})");
            m = inputTextarea.match(regex1);
            if (m) {
                alert("ASIN=" + m[4]);
                console.log(m[4]);
                var pulledASIN = m[4];
                myData.ASIN = pulledASIN;
            }
            // Regex 2
            if (!m) { 
                m = inputTextarea.match("/([a-zA-Z0-9]{10})(?:[/?]|$)");
                myData.ASIN = m;
            }

            // If there is an ASIN use it as the itemIds
           if (myData.ASIN){
               itemId = myData.ASIN;
           }

            //Call to API that return JSON string of product
            var thisurl2 = 'https://restaurant-booking-66070.firebaseapp.com/321?ASIN='...