Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katydorjee/bcc897d87b019f4b5837123da8aa1010 to your computer and use it in GitHub Desktop.
Save katydorjee/bcc897d87b019f4b5837123da8aa1010 to your computer and use it in GitHub Desktop.
URL shortening with short.io using AMPScript
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