Subversion Repositories munaweb

Rev

Rev 15 | Rev 19 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
<!DOCTYPE html>
2
<html lang="en">
3
 
4
<head>
5
    <title>eBay Listing Promotion</title>
6
    <meta charset="UTF-8">
7
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
9
    <link rel="icon" href="favicon.ico" type="image/x-icon">
10
 
11
    <script src="js/jquery.js"></script>
12
    <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
13
    <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
14
    <link rel="stylesheet" href="css/style.css">
15
    <script src="js/XMLWriter.js"></script>
16
    <script src="js/lodash.min.js"></script>
17
    <script src="js/moment.js"></script>
12 - 18
    <script src="js/moment-timezone-with-data-2012-2022.min.js"></script>
2 - 19
    <script src="js/muna-tools.js"></script>
20
</head>
21
 
22
<body onload="return initConfig();">
23
    <div class="w3-main">
24
        <div class="w3-container w3-padding w3-margin w3-card-4">
25
            <div class="w3-container w3-gray" style="height:100px">
26
                <img class="w3-image" src="images/MUNA%20-%20Logo%20100x100.png" alt="MUNA Trading Logo" style="height:100px">
27
                <p id="connected" class="w3-xxlarge w3-right">eBay Listing Promotion
28
                    <input id="login" type="button" class="w3-btn w3-large w3-green w3-margin w3-round-large w3-ripple w3-right w3-hide" onclick="eBayLogin();" value="Login" />
29
               	</p>
30
            </div>
31
 
32
            <div class="w3-row">
33
                <div>
34
                    <form id="searchForm" class="w3-container w3-light-grey w3-padding w3-small" onsubmit="return getListingsForPromote();">
35
                        <div class="w3-container w3-card-2 w3-cell w3-padding">
36
                            <input id="promoteButton" type="button" class="w3-btn w3-large w3-red w3-margin w3-round-large w3-ripple" onclick="getListingsForPromote();" value="Promote" />
37
                        </div>
38
                    </form>
39
                </div>
40
                <div id="progressBarDiv" class="w3-container w3-padding w3-margin w3-card-4 w3-hide">
41
                  	<h2 id="progressBarHeader"></h2>
42
                    <div class="w3-light-grey">
43
                        <div id="progressBar" class="w3-container w3-green w3-center" style="width:0%">0%</div>
44
                    </div>
45
                </div>
46
                <div id="results" class="w3-container w3-padding w3-card-4 w3-hide"></div>
47
                <div id="logging" class="w3-container w3-padding"></div>
48
            </div>
49
        </div>
50
 
51
        <footer class="w3-container w3-center w3-border-top w3-margin">
17 - 52
            <div w3-include-html="php/footer.php"></div>
2 - 53
        </footer>
54
 
55
    </div>
56
 
57
    <script>
58
 
59
// Config
60
var configCampaignId = '10477406018';
6 - 61
var accessToken = '';
62
var refreshToken = '';
2 - 63
 
64
var pagesToProcess = 0;
10 - 65
var maxPagesToProcess = 0;
2 - 66
var pagesProcessed = 0;
67
var html = [];
68
 
69
// Initialize Configuration Variables
70
function initConfig() {
71
    eBayAuthToken = readCookie();
72
    if (eBayAuthToken.length > 0) {
73
        connected();
74
    }
75
 
76
    if (eBayAuthTokenFlag === false) {
77
        var x = document.getElementById("login");
78
        if (x.className.indexOf("w3-show") == -1) {
79
            x.className += " w3-show";
80
        }
81
    }
6 - 82
 
3 - 83
    getOAuthToken();
2 - 84
}
85
 
86
function requireNewLogin() {
87
    // dummy
88
}
89
 
90
function connected() {
91
    var x;
92
 
93
    eBayAuthTokenFlag = true;
94
    document.getElementById("connected").innerHTML += " (Connected)";
95
 
96
    x = document.getElementById("promoteButton");
97
    x.className = x.className.replace(" w3-red", " w3-black");
98
 
99
    x = document.getElementById("login");
100
    x.className = x.className.replace(" w3-show", "");
101
 
102
    x = document.getElementById("results");
103
    x.innerHTML = "";
104
    x.className = x.className.replace(" w3-show", "");
105
    x.className = x.className.replace("process-errors", "");
106
}
107
 
108
function getListingsForPromote() {
109
    var x;
110
 
111
    if (eBayAuthTokenFlag === false) {
112
        return;
113
    }
114
 
6 - 115
//    if (accessToken.length < 1) {
116
//        getOAuthToken();
117
//    } else if (refreshToken.length > 0) {
118
//        refreshApplicationToken(refreshToken);
119
//    }
120
 
121
    if (accessToken.length < 1) {
2 - 122
        return;
123
    }
124
 
125
    document.getElementById("logging").innerHTML = '';
126
 
127
    x = document.getElementById("results");
128
    if (x.className.indexOf("w3-show") == -1) {
129
        x.className += " w3-show";
130
    }
131
    x.innerHTML = '<p><strong>Retrieving Listings...</strong></p>';
132
    x.className = x.className.replace("process-errors", "");
133
 
134
    pagesToProcess = 1;
10 - 135
    maxPagesToProcess = 0;
2 - 136
    pagesProcessed = 0;
137
    initProgressBar("Retrieving Listings...");
138
    eBaySearch(1);
139
 
140
    function checkpagesToProcess() {
141
        if (pagesToProcess > 0) {
142
            window.setTimeout(checkpagesToProcess, 300); // wait 100 milliseconds
143
        } else {
144
            endProgressBar();
145
            processCurrentAds();
146
        }
147
    }
148
 
149
    checkpagesToProcess();
150
}
151
 
152
function processCurrentAds() {
153
    adsToRead = 1;
154
    getCurrentAds(1);
155
 
156
    function checkAdsToRead() {
157
        if (adsToRead > 0) {
158
            window.setTimeout(checkAdsToRead, 100); // wait 100 milliseconds
159
        } else {
160
            updateAds();
161
        }
162
    }
163
 
164
    checkAdsToRead();
165
}
166
 
167
function updateAds() {
168
    var i = 1;
169
    var pt = document.getElementById("promoteTable");
170
    var x;
171
    var updateList = [];
172
    var addList = [];
173
    var entry;
174
    var maxAds = 500;
175
 
176
    adsToUpdate = 0;
177
 
178
    for (i = 1; i < pt.rows.length; i++) {
179
        if (pt.rows[i].cells[1].innerHTML != pt.rows[i].cells[3].innerHTML) {
180
            entry = '{"bidPercentage":"' + pt.rows[i].cells[1].innerHTML + '","listingId" : "' + pt.rows[i].cells[0].innerHTML + '"}';
181
            if (pt.rows[i].cells[2].innerHTML.length > 0) {
182
                if (updateList.indexOf(entry) == -1) {
183
                    updateList.push(entry);
184
                }
185
            } else {
186
                if (addList.indexOf(entry) == -1) {
187
                    addList.push(entry);
188
                }
189
            }
190
        }
191
    }
192
 
193
    for (i = 0; (i * maxAds) < updateList.length; i++) {
194
        ++adsToUpdate;
195
        updateAd(1, updateList.slice(i * maxAds, (i + 1) * maxAds));
196
    }
197
 
198
    for (i = 0; (i * maxAds) < addList.length; i++) {
199
        ++adsToUpdate;
200
        updateAd(0, addList.slice(i * maxAds, (i + 1) * maxAds));
201
    }
202
 
203
    function checkAdsToUpdate() {
204
        if (adsToUpdate > 0) {
205
            window.setTimeout(checkAdsToUpdate, 100); // wait 100 milliseconds
206
        } else {
207
            x = document.getElementById("results");
208
            x.innerHTML += '<p><strong>Report Finished!</strong></p>';
209
            if (!x.className.includes("process-errors")) {
210
                setTimeout(function() {
211
                    x.className = x.className.replace(" w3-show", "");
212
                }, 3000);
213
            }
214
        }
215
    }
216
 
217
    checkAdsToUpdate();
218
}
219
 
220
function getCurrentAds(pageNumber) {
221
    var i;
222
    var response;
223
    var limit = 500;
224
    url = configeBayAdCampaign;
225
    url += configCampaignId;
226
    url += '/ad?';
227
    url += 'offset=';
228
    url += (pageNumber - 1) * limit;
229
    url += '&limit=';
230
    url += limit;
231
 
232
    var xhttp = new XMLHttpRequest();
233
 
234
    xhttp.onreadystatechange = function() {
235
        if (this.readyState == 4) {
236
            if (this.status == 200) {
237
                response = JSON.parse(this.responseText);
238
 
239
                for (i = 0; i < response.ads.length; i++) {
240
                    itemId = response.ads[i].listingId;
241
                    if (document.getElementById('AdId' + itemId) !== null) {
242
                        document.getElementById('AdId' + itemId).innerHTML = response.ads[i].adId;
243
                        document.getElementById('CurrentRate' + itemId).innerHTML = response.ads[i].bidPercentage;
244
                    }
245
                }
246
 
247
                if (Number(response.total) > (pageNumber * limit)) {
248
                    ++adsToRead;
249
                    document.getElementById("results").innerHTML += '<p><strong>Retrieving Ads (' + pageNumber + '/' + Number((response.total / limit) + 1).toFixed(0) + ')</strong></p>';
250
                    getCurrentAds(pageNumber + 1);
251
                }
252
            }
253
 
254
            --adsToRead;
255
        }
256
    };
257
 
258
    xhttp.open("GET", configProxyUrl, true);
259
    xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
6 - 260
    xhttp.setRequestHeader('X-Authorization', 'Bearer ' + accessToken);
2 - 261
    xhttp.send();
262
}
263
 
264
function updateAd(flag, list) {
265
    var xhttp;
266
    var json;
6 - 267
    var i, j;
2 - 268
    var obj;
6 - 269
    var errors;
2 - 270
 
271
    if (list.length === 0) {
272
        return;
273
    }
274
 
275
    json = '{"requests":[' + list.join(',') + ']}';
276
 
277
    if (flag) {
278
        url = configeBayAdCampaign;
279
        url += configCampaignId;
280
        url += '/bulk_update_ads_bid_by_listing_id';
281
 
282
        xhttp = new XMLHttpRequest();
283
 
284
        xhttp.onreadystatechange = function() {
285
            if (this.readyState == 4) {
286
                obj = JSON.parse(this.responseText);
287
                if (this.status == 200 || this.status == 207) {
288
                    for (i = 0; i < obj.responses.length; i++) {
289
                        if (Number(obj.responses[i].statusCode) == 200) {
290
                            document.getElementById('AdId' + obj.responses[i].listingId).innerHTML = obj.responses[i].adId;
291
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).innerHTML = 'Updated';
292
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).style.color = 'green';
293
                        } else {
294
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).innerHTML = 'Update Failed (';
6 - 295
                            errors = getJsonArray(obj.responses[i].errors);
296
                            if (errors[0] !== undefined) {
297
                                document.getElementById('UpdateStatus' + obj.responses[i].listingId).innerHTML += errors[0].message;
2 - 298
                            } else if (obj.responses[i].statusCode !== undefined) {
6 - 299
                                document.getElementById('UpdateStatus' + obj.responses[i].listingId).innerHTML += " " + obj.responses[i].statusCode;
2 - 300
                            }
301
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).innerHTML += ')';
302
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).style.color = 'red';
303
                        }
304
                    }
305
                } else {
306
                    var x = document.getElementById("results");
307
                    x.className += " process-errors";
308
                    x.innerHTML += '<p class="w3-red">Bulk Update Ads: <strong>' + this.status + '</strong></p>';
309
                }
310
 
311
                --adsToRead;
312
            }
313
        };
314
 
315
        xhttp.open("POST", configProxyUrl, true);
316
        xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
6 - 317
        xhttp.setRequestHeader('X-Authorization', 'Bearer ' + accessToken);
2 - 318
        xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
319
        xhttp.send(json);
320
 
321
    } else {
322
        url = configeBayAdCampaign;
323
        url += configCampaignId;
324
        url += '/bulk_create_ads_by_listing_id';
325
 
326
        xhttp = new XMLHttpRequest();
327
 
328
        xhttp.onreadystatechange = function() {
329
            if (this.readyState == 4) {
330
                obj = JSON.parse(this.responseText);
331
                if (this.status == 200 || this.status == 207) {
332
                    for (i = 0; i < obj.responses.length; i++) {
333
                        if (Number(obj.responses[i].statusCode) == 201) {
334
                            document.getElementById('AdId' + obj.responses[i].listingId).innerHTML = obj.responses[i].adId;
335
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).innerHTML = 'Added';
336
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).style.color = 'green';
337
                        } else {
6 - 338
                            errors = getJsonArray(obj.responses[i].errors);
339
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).innerHTML = 'Add Failed (' + getJsonValue(errors[0].message) + ')';
2 - 340
                            document.getElementById('UpdateStatus' + obj.responses[i].listingId).style.color = 'red';
341
                        }
342
                    }
343
                } else {
344
                    var x = document.getElementById("results");
345
                    x.className += " process-errors";
346
                    x.innerHTML += '<p class="w3-red">Bulk Create Ads: <strong>' + this.status + '</strong></p>';
347
                }
348
 
349
                --adsToRead;
350
            }
351
        };
352
 
353
        xhttp.open("POST", configProxyUrl, true);
354
        xhttp.setRequestHeader("X-Proxy-Url", encodeURI(url));
6 - 355
        xhttp.setRequestHeader('X-Authorization', 'Bearer ' + accessToken);
2 - 356
        xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
357
        xhttp.send(json);
358
    }
359
 
360
    --adsToUpdate;
361
}
362
 
363
 
364
// Build an HTML table to display search results
365
function eBaySearch(pageNo) {
366
    var i;
367
    var xml;
368
 
369
    if (eBayAuthTokenFlag === false) {
370
        return;
371
    }
372
 
373
    var xw = new XMLWriter('UTF-8', '1.0');
374
    var xhr = new XMLHttpRequest();
375
 
376
    if (!createAddXMLSearch(xw, xhr, 'GetSellerList', pageNo)) {
377
        return;
378
    }
379
 
380
    xml = xw.flush();
381
    xw.close();
382
 
383
    xhr.onload = function() {
10 - 384
        var jsonObj = XMLparse(xhr.responseXML, false);
385
        var obj = jsonObj.GetSellerListResponse;
2 - 386
        var returnCode = obj.Ack;
387
 
388
        var x = document.getElementById("results");
389
 
390
        if (returnCode == 'Success') {
391
            createTable(obj.ItemArray, pageNo, Number(obj.PaginationResult.TotalNumberOfPages));
392
 
393
            if (Number(obj.PaginationResult.TotalNumberOfPages) > pageNo) {
394
                maxPagesToProcess = Number(obj.PaginationResult.TotalNumberOfPages);
395
                ++pagesToProcess;
396
                eBaySearch(pageNo + 1);
397
            }
398
 
399
            updateProgressBar(maxPagesToProcess, pagesProcessed);
400
        } else {
401
            x.className += " process-errors";
402
            x.innerHTML += '<p class="w3-red"><strong>' + returnCode + ':</strong></p>';
6 - 403
            var errors = getJsonArray(obj.Errors);
2 - 404
            x.innerHTML += "<p>";
6 - 405
            for (i = 0; i < errors.length; i++) {
406
                x.innerHTML += errors[i].SeverityCode + " (" + errors[i].ErrorCode + "): " + escapeHtml(errors[i].LongMessage) + "<br/>";
2 - 407
            }
408
            x.innerHTML += "</p>";
409
        }
410
 
411
        --pagesToProcess;
412
        ++pagesProcessed;
413
 
414
        document.getElementById("logging").innerHTML = html.join('');
415
        updateProgressBar(maxPagesToProcess, pagesProcessed);
416
    };
417
 
418
    xhr.send(xml);
419
}
420
 
421
function createAddXMLSearch(xw, xhr, callname, pageNo) {
422
    var startDate = moment(moment().subtract(31, "days").format('YYYY-MM-DD') + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
423
    var todayDate = moment(moment().format('YYYY-MM-DD') + " 23:59:59", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
424
    var endDate = moment(moment().add(31, "days").format('YYYY-MM-DD') + " 00:00:00", "YYYY-MM-DD HH:mm:ss").tz("UTC").toISOString();
425
 
426
    xw.writeStartDocument();
427
    xw.writeStartElement(callname + "Request");
428
    xw.writeAttributeString('xmlns', 'urn:ebay:apis:eBLBaseComponents');
429
 
430
    xw.writeStartElement('RequesterCredentials');
431
    xw.writeElementString('eBayAuthToken', eBayAuthToken);
432
    xw.writeEndElement(); /* RequesterCredentials */
433
 
10 - 434
    xw.writeElementString('DetailLevel', 'ItemReturnDescription');
2 - 435
    xw.writeElementString('StartTimeFrom', startDate);
436
    xw.writeElementString('StartTimeTo', todayDate);
437
    xw.writeElementString('EndTimeFrom', todayDate);
438
    xw.writeElementString('EndTimeTo', endDate);
439
    xw.writeElementString('OutputSelector', 'ItemArray.Item.ItemID');
440
    xw.writeElementString('OutputSelector', 'ItemArray.Item.ListingType');
441
    xw.writeElementString('OutputSelector', 'PaginationResult');
442
    xw.writeElementString('OutputSelector', 'ItemArray.Item.SellingStatus.ConvertedCurrentPrice');
443
    xw.writeStartElement('Pagination');
444
    xw.writeElementString('EntriesPerPage', '200');
445
    xw.writeElementString('PageNumber', '' + pageNo);
446
    xw.writeEndElement(); /* Pagination*/
447
 
448
    xw.writeElementString('ErrorLanguage', 'en_US');
449
    xw.writeElementString('Version', configeBayTradingVersion);
450
    xw.writeElementString('WarningLevel', configWarningLevel);
451
 
452
    xw.writeEndElement(); /* xmlrequest */
453
    xw.writeEndDocument();
454
 
455
    xhr.open('POST', configProxyUrl, true);
456
    xhr.setRequestHeader('Content-Type', 'text/xml');
457
    xhr.setRequestHeader('X-EBAY-API-APP-NAME', configAppid);
458
    xhr.setRequestHeader('X-EBAY-API-COMPATIBILITY-LEVEL', configeBayTradingVersion);
459
    xhr.setRequestHeader('X-EBAY-API-CALL-NAME', callname);
460
    xhr.setRequestHeader('X-EBAY-API-SITEID', '0');
461
    xhr.setRequestHeader('X-EBAY-API-DEV-NAME', '');
462
    xhr.setRequestHeader('X-EBAY-API-CERT-NAME', '');
463
    xhr.setRequestHeader('X-Proxy-URL', configServiceEndpoint);
464
 
465
    return true;
466
}
467
 
468
function createTable(obj, pageNumber, totalPages) {
469
    var currentPrice;
470
    var adRate;
471
 
472
    if (pageNumber == 1) {
473
        document.getElementById("logging").innerHTML = '';
474
        html = [];
475
 
476
        html.push('<h3>Listing Promotions</h3>');
477
        html.push('<div class="w3-responsive">');
478
        html.push('<table id="promoteTable" class="w3-table-all w3-hoverable">');
479
        html.push('<thead>');
480
        html.push('<tr>');
481
 
482
        html.push(tableHeader('Item ID'));
483
        html.push(tableHeader('New Ad Rate'));
484
        html.push(tableHeader('Ad Id'));
485
        html.push(tableHeader('Current Ad Rate'));
486
        html.push(tableHeader('Create/Update Status'));
487
 
488
        html.push('</tr>');
489
        html.push('</thead>');
490
        html.push('<tbody>');
491
    }
492
 
10 - 493
    for (var entry = 0; entry < obj.Item.length; entry++) {
494
        var item = obj.Item[entry];
2 - 495
 
10 - 496
        if (item.ListingType == 'Chinese') {
2 - 497
            continue;
498
        }
499
 
10 - 500
        currentPrice = Number(item.SellingStatus.ConvertedCurrentPrice.text).toFixed(2);
2 - 501
 
502
        // minimum ad rate is 1.00%
503
        if (currentPrice > 99.99) {
504
            adRate = 2.0;
505
        } else if (currentPrice > 49.99) {
506
            adRate = 2.7;
507
        } else if (currentPrice > 29.99) {
508
            adRate = 3.0;
509
        } else if (currentPrice > 19.99) {
510
            adRate = 3.2;
511
        } else if (currentPrice > 14.99) {
512
            adRate = 3.5;
513
        } else if (currentPrice > 9.99) {
514
            adRate = 3.7;
515
        } else if (currentPrice > 4.99) {
516
            adRate = 4.0;
517
        } else if (currentPrice > 3.99) {
518
            adRate = 4.2;
519
        } else {
520
            continue;
521
        }
522
 
523
        html.push('<tr>');
524
 
10 - 525
        html.push(tableCell(item.ItemID));
2 - 526
        html.push(tableCell(Number(adRate).toFixed(1)));
10 - 527
        html.push(tableCellLabel('AdId' + item.ItemID));
528
        html.push(tableCellLabel('CurrentRate' + item.ItemID));
529
        html.push(tableCellLabel('UpdateStatus' + item.ItemID));
2 - 530
 
531
        html.push('</tr>');
532
    }
533
 
534
    if (pageNumber == totalPages) {
535
        html.push('</tbody>');
536
        html.push('</table>');
537
        html.push('</div>');
538
    }
539
}
540
 
3 - 541
function getOAuthToken() {
542
    var code = "";
543
 
544
	var win = window.open(configeBayLoginUrl, "eBay OAUTH", "");
545
 
546
	var pollTimer = window.setInterval(function() {
547
		if (win.closed !== false) {
548
			window.clearInterval(pollTimer);
549
			getApplicationToken(code);
550
		} else {
551
		    if (code === null || code.length === 0) {
552
                try {
553
                  code = getUrlParameter(win, 'code');
554
                } catch(err) {
555
                  // empty
6 - 556
                }
3 - 557
		    }
558
		}
559
	}, 200);
6 - 560
 
3 - 561
}
562
 
563
function getApplicationToken(code) {
564
    var param;
6 - 565
 
3 - 566
    param = 'grant_type=authorization_code';
567
    param += '&code=' + code;
568
    param += '&redirect_uri=' + configRuName;
6 - 569
 
3 - 570
    var xhttp = new XMLHttpRequest();
571
 
572
    xhttp.onreadystatechange = function() {
573
        if (this.readyState == 4) {
574
            if (this.status == 200) {
575
                response = JSON.parse(this.responseText);
576
 
6 - 577
            	accessToken = getJsonValue(response.access_token);
578
            	refreshToken = getJsonValue(response.refresh_token);
3 - 579
            }
580
        }
581
    };
582
 
583
    xhttp.open("POST", configProxyUrl, true);
584
    xhttp.setRequestHeader("X-Proxy-Url", configOauthTokenUrl);
585
    xhttp.setRequestHeader('X-Authorization', 'Basic ' + btoa(configAppid + ':' + configCertid));
4 - 586
    xhttp.setRequestHeader('X-DECODE-PARAMS', '1');
6 - 587
    xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
588
    xhttp.send(param);
589
}
3 - 590
 
6 - 591
function refreshApplicationToken(code) {
592
    var param;
593
 
594
    param = 'grant_type=refresh_token';
595
    param += '&refresh_token=' + code;
596
    param += '&scope=https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.marketing';
597
 
598
    var xhttp = new XMLHttpRequest();
599
 
600
    xhttp.onreadystatechange = function() {
601
        if (this.readyState == 4) {
602
            if (this.status == 200) {
603
                response = JSON.parse(this.responseText);
604
 
605
            	accessToken = getJsonValue(response.access_token);
606
            	refreshToken = getJsonValue(response.refresh_token);
607
            }
608
        }
609
    };
610
 
611
    xhttp.open("POST", configProxyUrl, true);
612
    xhttp.setRequestHeader("X-Proxy-Url", configOauthTokenUrl);
613
    xhttp.setRequestHeader('X-Authorization', 'Basic ' + btoa(configAppid + ':' + configCertid));
614
    xhttp.setRequestHeader('X-DECODE-PARAMS', '1');
3 - 615
    xhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
616
    xhttp.send(param);
617
}
2 - 618
    </script>
17 - 619
    <script>includeHTML();</script>
2 - 620
 
621
</body>
622
</html>