Skip to content

Instantly share code, notes, and snippets.

@axeda
Created August 3, 2012 20:14
Show Gist options
  • Save axeda/3251114 to your computer and use it in GitHub Desktop.
Save axeda/3251114 to your computer and use it in GitHub Desktop.
Scribe Example
//setup the scribe client
org.scribe.oauth.OAuthService service = new org.scribe.builder.ServiceBuilder() .provider(org.scribe.builder.api.TwitterApi.class).apiKey(customer_key).apiSecret(customer_secret).build();
// create the scribe request to the Twitter API URL - 'update my status' in this case
org.scribe.model.OAuthRequest request = new org.scribe.model.OAuthRequest(org.scribe.model.Verb.POST, "http://api.twitter.com/1/statuses/update.xml");
//add the status to the body you want to tweet
request.addBodyParameter("status", status);
//re-generate the access token and use it to sign the request (the final step before sending anything 'oauth secured)
org.scribe.model.Token accessToken= new org.scribe.model.Token(oauth_key, oauth_secret);
service.signRequest(accessToken, request);
//actually invoke the twitter api
org.scribe.model.Response response = request.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment