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
RS_SforceRS_Sforce 

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();
		req.setMethod('POST');
		req.setEndpoint('https://api.twitter.com/1/statuses/update.xml');
		req.setHeader('Content-Type','application/x-www-form-urlencoded');
		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());

 

Regards,

R

 

RS_SforceRS_Sforce

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.

 

Regards

Navatar_DbSupNavatar_DbSup

Hi,

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

 

OAuth class = http://code.google.com/p/sfdc-oauth-playground/source/browse/trunk/OAuth/src/classes/OAuth.cls?r=10

 

AuthController  classes = http://code.google.com/p/sfdc-oauth-playground/source/browse/trunk/OAuth/src/classes/AuthController....

 

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:

http://boards.developerforce.com/t5/General-Development/URGENT-I-AM-STUCKED/m-p/415527#M68077

 

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

 

 

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

Thanks in advance,
satheesh