Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save katydorjee/e083c31374ed20e1ee19c66da738d448 to your computer and use it in GitHub Desktop.

Select an option

Save katydorjee/e083c31374ed20e1ee19c66da738d448 to your computer and use it in GitHub Desktop.
Bitly API to Shorten the URL in Ampscript
%%[
SET @query = "i love momo"
SET @URL = TRIM(HTTPGet(Concat("https://api-ssl.bitly.com/v3/shorten?access_token=<Access Token>&format=txt&longUrl=https%3A%2F%2Fwww.google.com/#q=",@query)))
]%%
%%=v(@URL)=%%
<!--
Note: You need to create Bitly account and get the 'Access Token'
https://bitly.com
-->
@katydorjee
Copy link
Author

Here is the version 4 bitly URL shorter API

POST /v4/shorten HTTP/1.1
Host: api-ssl.bitly.com
Authorization: Bearer < access_token>
Content-Type: application/json
Content-Length: 123

{ "group_guid": "Bj2i6uFEYQK", "domain": "bit.ly", "long_url": "https://www.google.com/search?q=i+love+momo/" }

@DanielaMartinez24
Copy link

Hi @katydorjee! I need your help
I'm trying to create a short url but with the new version (v4)
Should I replace like this:???

%%[
SET @query = "i love momo"
SET @url = TRIM(HTTPGet(Concat("https://api-ssl.bitly.com/v4/shorten?access_token=&format=txt&longUrl=https%3A%2F%2Fwww.google.com/#q=",@query)))
]%%
%%=v(@url)=%%

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment