Created
January 13, 2024 11:34
-
-
Save katydorjee/bcc897d87b019f4b5837123da8aa1010 to your computer and use it in GitHub Desktop.
URL shortening with short.io using AMPScript
This file contains 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
var @headerKey, @headerVal, @payload, @response, @unsubscribeURL | |
set @headerKey = "authorization" | |
set @headerVal = "<MyApi_Token>" | |
set @myLongURL = "https://mylongUrlDomain.com/?q=some_lenghty_query_param_value" | |
set @payload = Concat('{ | |
"allowDuplicates": false, | |
"domain": "my.customdomain.com", | |
"originalURL": "', @myLongURL, '" | |
}') | |
HTTPPost("https://api.short.io/links", "application/json", @payload, @response, @headerKey, @headerVal) | |
set @myShortURL = RegExMatch(@response, '"shortURL":"(.*?)"', 1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment