Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to use twitter API using scribe jar
    primarykey
    data
    text
    <p>I want to write code in java to get users all "following user-id" information from twitter I have searched a lot and find out scribe library to use twitter API. I have downloaded scribe jar and included in my eclipse java project, My problem is when i am trying to run following code:</p> <pre><code>import java.util.Scanner; import org.scribe.builder.*; import org.scribe.builder.api.*; import org.scribe.model.*; import org.scribe.oauth.*; public class TwitterExample { private static final String PROTECTED_RESOURCE_URL = "http://api.twitter.com /1.1/account/verify_credentials.json"; public static void main(String[] args) { // If you choose to use a callback, "oauth_verifier" will be the return value by Twitter (request param) OAuthService service = new ServiceBuilder() .provider(TwitterApi.class) .apiKey("6icbcAXyZx67r8uTAUM5Qw") .apiSecret("SCCAdUUc6LXxiazxH3N0QfpNUvlUy84mZ2XZKiv39s") .build(); Scanner in = new Scanner(System.in); System.out.println("=== Twitter's OAuth Workflow ==="); System.out.println(); // Obtain the Request Token System.out.println("Fetching the Request Token..."); Token requestToken = service.getRequestToken(); System.out.println("Got the Request Token!"); System.out.println(); System.out.println("Now go and authorize Scribe here:"); System.out.println(service.getAuthorizationUrl(requestToken)); System.out.println("And paste the verifier here"); System.out.print("&gt;&gt;"); Verifier verifier = new Verifier(in.nextLine()); System.out.println(); // Trade the Request Token and Verfier for the Access Token System.out.println("Trading the Request Token for an Access Token..."); Token accessToken = service.getAccessToken(requestToken, verifier); System.out.println("Got the Access Token!"); System.out.println("(if your curious it looks like this: " + accessToken + " )"); System.out.println(); // Now let's go and ask for a protected resource! System.out.println("Now we're going to access a protected resource..."); OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL); request.addBodyParameter("status", "this is sparta! *"); service.signRequest(accessToken, request); Response response = request.send(); System.out.println("Got it! Lets see what we found..."); System.out.println(); System.out.println(response.getBody()); System.out.println(); System.out.println("Thats it man! Go and build something awesome with Scribe! :)"); } } </code></pre> <p>I know this code is not about getting "following-user id" information actually this code is available on following link as a runnable example of scribe and in some places I have to fill my keys.</p> <p><a href="https://github.com/fernandezpablo85/scribe-java/blob/master/src/test/java/org/scribe/examples/TwitterExample.java" rel="nofollow">https://github.com/fernandezpablo85/scribe-java/blob/master/src/test/java/org/scribe/examples/TwitterExample.java</a></p> <p>when I am running above code I am getting following error: </p> <p>=== Twitter's OAuth Workflow ===</p> <p>Fetching the Request Token... Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64 at org.scribe.services.HMACSha1SignatureService.doSign(HMACSha1SignatureService.java:47) at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:33) at org.scribe.oauth.OAuth10aServiceImpl.getSignature(OAuth10aServiceImpl.java:122) at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:63) at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:43) at assignment.TwitterExample.main(TwitterExample.java:30) Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64 at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 6 more please help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload