}
public String prepareOAuthHeaderForAccesingResources(Properties props,
String method, String resource, String updateStatus)
throws Exception {
OAuthMessage message = new OAuthMessage(method, resource, null, null);
message.addParameter(OAuth.OAUTH_NONCE, System.nanoTime() + "");
message.addParameter(OAuth.OAUTH_VERSION, OAuth.VERSION_1_0);
message.addParameter(OAuth.OAUTH_TIMESTAMP,
(System.currentTimeMillis() / 1000) + "");
message.addParameter(OAuth.OAUTH_SIGNATURE_METHOD, OAuth.HMAC_SHA1);
message.addParameter(OAuth.OAUTH_TOKEN, props
.getProperty("accessToken"));
message.addParameter(OAuth.OAUTH_CONSUMER_KEY, props
.getProperty("consumerKey"));
if (updateStatus != null) {
// the parameter used by twitter on
message.addParameter("status", updateStatus);
}
OAuthServiceProvider provider = new OAuthServiceProvider(props
.getProperty("requestUrl"), props
.getProperty("authorizationUrl"), props
.getProperty("accessUrl"));
OAuthConsumer consumer = new OAuthConsumer("", props
.getProperty("consumerKey"), props
.getProperty("consumerSecret"), provider);
OAuthAccessor accessor = new OAuthAccessor(consumer);
accessor.tokenSecret = props.getProperty("tokenSecret");
message.sign(accessor);
return message.getAuthorizationHeader(resource);
}