111 lines
3.0 KiB
Plaintext
111 lines
3.0 KiB
Plaintext
<!-- #include File="../include/Header.asp"-->
|
|
<%
|
|
''/*
|
|
''https://code.google.com/archive/p/crypto-js/
|
|
''https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/crypto-js/CryptoJS%20v3.1.2.zip
|
|
''*/
|
|
''/*
|
|
''CryptoJS v3.1.2
|
|
''code.google.com/p/crypto-js
|
|
''(c) 2009-2013 by Jeff Mott. All rights reserved.
|
|
''code.google.com/p/crypto-js/wiki/License
|
|
''*/
|
|
%>
|
|
<script type="text/javascript" src="/CryptoJS/rollups/hmac-sha256.js"></script>
|
|
<script type="text/javascript" src="/CryptoJS/components/enc-base64.js"></script>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<div class="row justify-content-md-center p-3">
|
|
<div class="col-xl-4 col-lg-offset-4 mt-5">
|
|
<div class="login-panel panel panel-default">
|
|
<div class="panel-heading">
|
|
<h3 class="panel-title"></h3>
|
|
</div>
|
|
<div class="p-3 border rounded shadow-sm">
|
|
<div class="d-flex align-items-center">
|
|
<span style="width:20%" class="p-1"><img src="/img/non_logo.png" style="width:100%"/></span>
|
|
|
|
</div>
|
|
<hr>
|
|
<div class="d-flex align-items-center" id="consolelog" >
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
|
|
<script>
|
|
var timestamp = new Date().getTime().toString();
|
|
const fromPhoneNumber = "01020529420";
|
|
const serviceID = "ncp:sms:kr:260035111992:kiwi_biz_message";
|
|
const accessKey = "331321C8B4C22DC3416D";
|
|
const secretKey = "C5286BE6EC55FE0D3E70EA5A653A2816AE65F394";
|
|
|
|
function makeSignature() {
|
|
var space = " "; // one space
|
|
var newLine = "\n"; // new line
|
|
var method = "POST"; // method
|
|
var url = "/sms/v2/services/" + encodeURIComponent(serviceID) + "/messages";
|
|
|
|
var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, secretKey);
|
|
hmac.update(method);
|
|
hmac.update(space);
|
|
hmac.update(url);
|
|
hmac.update(newLine);
|
|
hmac.update(timestamp);
|
|
hmac.update(newLine);
|
|
hmac.update(accessKey);
|
|
|
|
var hash = hmac.finalize();
|
|
|
|
return hash.toString(CryptoJS.enc.Base64);
|
|
}
|
|
|
|
function sendSMS(phoneNumber, contentStr){
|
|
var bodyObj = {
|
|
"type" : "SMS",
|
|
"contentType" : "COMM",
|
|
"countryCode" : "82",
|
|
"from" : fromPhoneNumber,
|
|
"content" : contentStr,
|
|
"messages" : [{"to" : phoneNumber}]
|
|
};
|
|
|
|
var headerObj = {
|
|
"Contype":"application/json; charset=utf-8",
|
|
"acckey":accessKey,
|
|
"apitsp":timestamp,
|
|
"sigkey":makeSignature()
|
|
};
|
|
|
|
var url = "https://sens.apigw.ntruss.com/sms/v2/services/" + encodeURIComponent(serviceID) + "/messages";
|
|
var param = {
|
|
"url" : url,
|
|
"body" : JSON.stringify(bodyObj)
|
|
|
|
};
|
|
param = Object.assign(param, headerObj);
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
data: param,
|
|
url: "./sproxy.asp",
|
|
success: function (res) {
|
|
console.log(res);
|
|
},
|
|
error: function(err){
|
|
console.log(err);
|
|
}
|
|
});
|
|
}
|
|
|
|
sendSMS("01047280325", "하이");
|
|
</script>
|
|
|
|
</html>
|
|
|