Created
September 2, 2018 18:05
-
-
Save matrostik/6be50bb500c11c0f974fcd885924e945 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%[SET @MobileFinal = "614xxxxxxxx"]%% | |
<script runat="server"> | |
Platform.Load("core", "1"); | |
var mobileNumber = Variable.GetValue("@MobileFinal"); | |
var mobileNumberList = []; | |
mobileNumberList[0] = mobileNumber; | |
var mobileNumbers = Stringify(mobileNumberList); | |
//Request accesstoken | |
var url = 'https://auth.exacttargetapis.com/v1/requestToken'; | |
var contentType = 'application/json'; | |
var client_id = 'your_client_id' | |
var client_secret = 'your_client_secret' | |
var payload = '{"clientId":"CLIENT_ID","clientSecret":"CLIENT_SECRET"}'; | |
payload = payload.replace('CLIENT_ID', client_id); | |
payload = payload.replace('CLIENT_SECRET', client_secret); | |
var result = HTTP.Post(url, contentType, payload, headerNames, headerValues); | |
var response = eval("(function(){return " + result.Response + ";})()"); | |
var accessToken = response.accessToken; | |
//Triggered SMS | |
url = 'http://www.exacttargetapis.com/sms/v1/messageContact/ujheyYYI/send'; | |
contentType = 'application/json'; | |
payload = '{"mobileNumbers":MOBILENUMBERS,"Subscribe":true,"Resubscribe":true,"keyword":"TEST","messageText": "Welcome","Override": "true"}'; | |
payload = payload.replace('MOBILENUMBERS', mobileNumbers); | |
var headerNames = ["Authorization"]; | |
var headerValues = ['Bearer ' + accessToken]; | |
result = HTTP.Post(url, contentType, payload, headerNames, headerValues); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment