SalesforceSalesforce Integration With Bitly

Salesforce Integration With Bitly

public class Salesforce_Bitly_Intigration {
    public Salesforce_Bitly_Intigration(){
        HttpRequest req = new HttpRequest();
        
        //WE CAN ALSO USE CUSTOM SETTINGS TO STORE THISE ENDPOINTS URLS, AND ACCESS TOKENS.
        String EndpointUrl = 'https://api-ssl.bitly.com/oauth/access_token';

        String Authorization = 'Basic ZTM5MiNmFiNDRk';
        //Where Authorization: is set to "Basic " + base64encode(client_id + ":" + client_secret).

        String Content_Type = 'application/x-www-form-urlencoded';
        
        req.setEndpoint(EndpointUrl); 
        req.setMethod('POST');
        
        req.setHeader('Authorization', Authorization);  
        req.setHeader('Content-Type', Content_Type);
        req.setBody('username=YOURUSERNAME&password=YOUREPASSWORD&grant_type=password');
        
        Http http = new Http();
        HTTPResponse res = http.send(req);   
        
        system.debug('status---'+res.getStatusCode());
        system.debug('message---'+res.getStatus());
        system.debug('body---'+res.getBody());
    }
    
}
RESPONSE
20:52:54:639 USER_DEBUG [20]|DEBUG|status---200
20:52:54:640 USER_DEBUG [21]|DEBUG|message---OK
20:52:54:640 USER_DEBUG [22]|DEBUG|body---{"access_token": "bdc0uudsfjks9023wenmfdsk13cc3"}

More References Of Bitly API’s

https://dev.bitly.com/docs/getting-started/introduction

https://dev.bitly.com/docs/getting-started/authentication

Hope this helps!!

For any kind of assistance on this, please feel free to contact me [email protected] do share and comment if you like it

- Advertisement -spot_img

More From UrbanEdge

Top Salesforce Flow Interview Questions & Answers 2024 Part – 3

Top Salesforce Flow Interview Questions & Answers 2024 Part...

Top Salesforce Flow Interview Questions & Answers 2024 Part – 2

This blog will explore some of the most commonly...

Best Practices for Lightning Web Components (LWC)

Lightning Web Components (LWC) is a modern framework by...

Top Salesforce Flow Interview Questions & Answers 2024 Part – 1

Flow Interview QuestionsWhat is Salesforce Flow?Types of Salesforce FlowsWhat...

Mastering Salesforce Flows: Streamline Your Business Processes with Ease

Understanding the benefits of using Salesforce FlowsKey components of...

Top Salesforce Static Code Analysis Tools: Enhancing Code Quality and Security

#Heading1Introduction2What is Salesforce?3The Importance of Code Analysis4Understanding Static Code...

Trigger Challenge #12: Understanding the Trigger on Account and its Impact on Salesforce Development

As a Salesforce developer, understanding how triggers work is...

Best Practices for Apex Triggers

Introduction Apex Triggers are a fundamental aspect of Salesforce development,...
- Advertisement -spot_img