Expand my Community achievements bar.

SOLVED

bityl url shortner to shorten url

Avatar

Level 3

Hi All,

 

i need code to do url shortning to send one of the sms campaign

 

Please help me how can i shorten that url

bityl url shortner to shorten url

please provide code/url ---how can we achieve that

 

@Manoj_Kumar_ 

@Craig_Thonis 

@ParthaSarathy

@AkshayAnand 

@Craig_Thonis 

@Manoj_Kumar_ 

@Amine_Abedour 

@Marcel_Szimonisz

@DavidKangni 

@Dhanesh_S 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @jefrii 

 

You can use this code to call bitly API

 var req = new HttpClientRequest("https://api-ssl.bitly.com/v4/shorten")
 req.header["Authorization"] = "Bearer TOKEN_HERE" ;
 req.header["Content-Type"] = "application/json";
 req.method = "POST";
 req.body = '{  "group_guid": "GROUP_UUID_HERE","domain": "bit.ly","long_url": "LONG_URL_HERE"}' ;
 try {       
      req.execute()
 var response = req.response;
        var res=JSON.parse(response.body);
        return res.link;   
     }
    catch(e)
        {
        return "unable to exceute api";
        }        

        req.disconnect()
 

 

this is just a sample code to get you started


     Manoj
     Find me on LinkedIn

View solution in original post

2 Replies

Avatar

Community Advisor

Hi @jefrii 

 

I too had a similar use case where I used rebrandly as our 3rd party. 

As I guess bitly is also an open source API, so you can create your account and keys to play around with the API projects. Once you are familiar with the body parameters which you need to send to bitly through an API call to get the shortened URL in response. You can create the same call in Adobe through JavaScript in a workflow and make the call to bitly to get the shortened URL in response after whitelisting the bitly URL in console.

 

Thanks,

Akshay

Avatar

Correct answer by
Community Advisor

Hello @jefrii 

 

You can use this code to call bitly API

 var req = new HttpClientRequest("https://api-ssl.bitly.com/v4/shorten")
 req.header["Authorization"] = "Bearer TOKEN_HERE" ;
 req.header["Content-Type"] = "application/json";
 req.method = "POST";
 req.body = '{  "group_guid": "GROUP_UUID_HERE","domain": "bit.ly","long_url": "LONG_URL_HERE"}' ;
 try {       
      req.execute()
 var response = req.response;
        var res=JSON.parse(response.body);
        return res.link;   
     }
    catch(e)
        {
        return "unable to exceute api";
        }        

        req.disconnect()
 

 

this is just a sample code to get you started


     Manoj
     Find me on LinkedIn