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
Zoya KhanZoya Khan 

Salesforce Integration With Facbook & Twitter

Hi ,

 

I want to integrate Facbook and Twitter application with my salesforce application. Can Any1 help me how to post and update status on Facbook wall and Twitter Using HTTP Request(OAuth). Is there any sample code available then please share.

 

Thanks!

Navatar_DbSupNavatar_DbSup

Hi,


You can use the below sample code to update the status in to twitter directly form salesforce
------------ SAMPLE CODE ------------
VF CODE:
<apex:inputTextarea id="tweetInput" onkeyup="return maxLength();" onKeyPress="return maxLength();" value="{!newTweet}" rows="2" cols="73"/>
<apex:commandButton id="tweetBtn" style="height:35px;" value="Tweet" action="{!postTweet}" />
Controller code:
*** post tweets into twitter*/
public String newTweet{get;set;}
public Void postTweet()
{
Http h = new Http();
HttpRequest req = new HttpRequest();
Method = 'POST';
req.setMethod(Method);
req.setEndpoint('https://api.twitter.com/1/statuses/update.xml');
newTweet = newTweet.replace('%','%25').replace('&','%26').replace('@','%40').replace(';','%3B').replace('?','%3F').replace('/','%2F').replace(':','%3A').replace('#','%23').replace('=','%3D').replace('+','%2B').replace('$','%24').replace(',','%2C').replace(' ','%20').replace('<','%3C').replace('>','%3E').replace('{','%7B').replace('}','%7D').replace('[','%5B').replace(']','%5D').replace('`','%60').replace('|','%7C').replace('\\','%5C').replace('^','%5E').replace('"','%22').replace('\'','%27').replace('!','%21').replace('*','%2A').replace('(','%28').replace(')','%29').replace('~','%7F');
req.setBody('status='+newTweet);
req.setHeader('Content-Type','application/x-www-form-urlencoded');

OAuth oa = new OAuth();
if(!oa.setService())
{
message=oa.message;
}
oa.sign(req);

HttpResponse res = h.send(req);
system.debug('&&&&&&&&&&&&&&&&7' + res.getBody());
PostTweetbody = res.getBody() + '___' + message;
newTweet = '';
}

 

 

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

Zoya KhanZoya Khan

Thank you, its works.

 

I want to do the same in facebook (post text on facebook wall) from apex buton. If you have work on salesforce integration with facebook , then please show some sample code regarding faceboook.

Plus i want to know, how we authorized with facebook application( getting access token/access token secret of facebook application)in salesforce.

 

Thanks!

Asia Naseer.

Bhawani SharmaBhawani Sharma

OAuth oa = new OAuth();

 

is it work?

Integrator9Integrator9
Hi When i use the Code Mentioned above it throws error Oauth is invalid, Can any one suggest how to use Oauth Thanks in advance
SubhamSubham

Hi AlL,

 

I want to get the tweets of my contacts who uses Twitter.
 Using Oauth.

 

How to get started.?

 

Thanks,

Subham

 

SF DEVSF DEV

Can we use salesforce twitter appexchange code to be modify as per our requirement. after integrating or installing?

Patel JigarPatel Jigar
Hi,
I am a final year MTech student and working on API integration as my dissertation work.Can anyone write the steps and code for salesforce integration with twitter through API??  it will be helpful for my dissertation..
Patel JigarPatel Jigar
Actually I have created the Twitter app and got the secrete key and all required keys and tokens but now after getting all the keys I have to apply those to the code and i need this code in which I put those tokens and keys.