Guest User

Untitled

a guest
Mar 23rd, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. %%[
  2. /* Get Subscribers Email Address */
  3. SET @email = RequestParameter("EmailAddress")
  4.  
  5. /* Get Access token using API creds */
  6. Var @body, @callstatus, @response
  7. Set @body = '{"clientId": "xxxxxx", "clientSecret": "yyyyyy"}'
  8. HTTPPost2("https://auth.exacttargetapis.com/v1/requestToken", "application/json", @body, True, @callstatus, @response)
  9. ]%%
  10.  
  11. <script runat="server">
  12. // Load response into SSJS for parsing
  13. Platform.Load("Core", "1")
  14. // get JSON from callstatus
  15. var callstatus = Variable.GetValue("@callstatus");
  16. // Parse the string to JSON
  17. callstatus = Platform.Function.ParseJSON(callstatus);
  18. // Get Access Token
  19. Variable.SetValue("@access_token",'BEARER ' + callstatus.accessToken);
  20. </script>
  21.  
  22. %%[
  23. /* Trigger the Journey via API event */
  24. Set @body = '{"ContactKey": @email, "EventDefinitionKey":"APIEvent-ad292469-4d77-17a9-e56d-b791b29b8b95", "EstablishContactKey": true, "Data": {"EmailAddress":@email}}'
  25. HTTPPost2("https://auth.exacttargetapis.com/interaction/v1/events", "application/json", @body, True, @callstatus, @response, 'Authorization', @access_token)
  26. ]%%
Add Comment
Please, Sign In to add comment