function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Twitter Integration

Hi All,


I am trying to connect salesforce to twitter, but when I make callout it throws exception to me:

<error code="53">Basic authentication is not supported</error>


I checked that twitter has turned on the basic authentication, but I am not sure how to call twitter from salesforce now.


My existing code is:

Http h = new Http();
		HttpRequest req = new HttpRequest();
		Blob headerValue = Blob.valueOf('username:password');
      	String authorizationHeader = 'OAuth ' + EncodingUtil.base64Encode(headerValue);
      	req.setHeader('Authorization', authorizationHeader);
		req.setBody('status=Test Data');
		HttpResponse res = h.send(req);
		system.debug('&&&&&&&&&&&&&&&&7' + res.getBody());






I checked that twitter had a turned off basic authenticatication. So I will have to go with OAuth.

I am not sure how to use OAuth code class in Apex and how I will make the call ?


Can someone help me as we are having a large community of champions.





In order to Authenticate you can make use of the OAuth , AuthController  classes .


OAuth class =


AuthController  classes =


Once Complete Authentication is done, then you store those permanent credentials (i.e., Access token) because they are used (along with your Consumer key and Consumer secret) to sign (i.e., authenticate) HTTP requests to Twitter’s APIs.


for moe detail follow below link:


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 



Have you completed the integration. I need to get the posts from twitter. Could you please share the code.

Thanks in advance,