thebleacher
Mar 4th, 2011, 08:15 AM
For a project we're trying to use spring social to post twitter and facebook updates.
I'm using a TwitterTemplate for communication with twitter like so:
public boolean postTweet(String pAccessToken, String pAccessTokenSecret, String pTweet){
TwitterTemplate tTwitter = new TwitterTemplate(fTwitterApiKey, fTwitterApiSecret, pAccessToken, pAccessTokenSecret);
if(pTweet == null || "".equals(pTweet))
throw new IllegalArgumentException("Tweet is empty");
try{
tTwitter.updateStatus(pTweet);
}
catch(SocialException e){
return false;
}
return true;
}
For the FacebookTemplate, this approach works perfectly. I keep on struggling with the TwitterTemplate. The accesstoken and accestokensecret are obtained by the OAuth dance client side and stored by the backend.
When I try to post a tweet I get the following exception:
org.springframework.social.AccountNotConnectedExce ption: Incorrect signature
I know requests to the twitter api should be signed, but my expectation was for spring social to handle that. Also, I fail to see how I could supply the TwitterTemplate with a signature.
I'm using a TwitterTemplate for communication with twitter like so:
public boolean postTweet(String pAccessToken, String pAccessTokenSecret, String pTweet){
TwitterTemplate tTwitter = new TwitterTemplate(fTwitterApiKey, fTwitterApiSecret, pAccessToken, pAccessTokenSecret);
if(pTweet == null || "".equals(pTweet))
throw new IllegalArgumentException("Tweet is empty");
try{
tTwitter.updateStatus(pTweet);
}
catch(SocialException e){
return false;
}
return true;
}
For the FacebookTemplate, this approach works perfectly. I keep on struggling with the TwitterTemplate. The accesstoken and accestokensecret are obtained by the OAuth dance client side and stored by the backend.
When I try to post a tweet I get the following exception:
org.springframework.social.AccountNotConnectedExce ption: Incorrect signature
I know requests to the twitter api should be signed, but my expectation was for spring social to handle that. Also, I fail to see how I could supply the TwitterTemplate with a signature.