Created
August 3, 2012 20:14
-
-
Save axeda/3251114 to your computer and use it in GitHub Desktop.
Scribe Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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