You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
|
<?php
|
|
$currentTime = time();
|
|
$twoMinutesLater = $currentTime - (2 * 60);
|
|
$now = gmdate("YmdHis", $twoMinutesLater);
|
|
$data = 'M0000.' . $now;
|
|
$sign = hash_hmac('SHA256', $data, 'B2D6395D2883E26C', false);
|
|
|
|
?>
|
|
|
|
<script>
|
|
function get_Auth() {
|
|
var api_key = '964C834F7BF2BB70';
|
|
var validation = "";
|
|
// var corsurl = 'http://cors-anywhere.herokuapp.com/';
|
|
// var apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth';
|
|
var apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'
|
|
headerParam = {
|
|
UserId: 'M0000',
|
|
Pwd: 'M012290493119',
|
|
TimestampUTC: <?= $now ?>,
|
|
Sign: '<?= $sign ?>'
|
|
};
|
|
obj = {
|
|
type: 'get',
|
|
// url: `${corsurl}${apiurl}`,
|
|
url: `${apiurl}`,
|
|
dataType: 'json',
|
|
headers: headerParam,
|
|
success: function(res) {
|
|
validation = res.Data['CHI_Authorization'];
|
|
console.log(validation);
|
|
// console.log(res);
|
|
// console.log()
|
|
// window.parent.postMessage(validation,'http://localhost:3000');
|
|
// window.parent.postMessage(validation,'https://masada.com.tw');
|
|
return validation;
|
|
}
|
|
};
|
|
jQuery.ajax(obj);
|
|
// return jQuery.ajax(obj);
|
|
}
|
|
</script>
|