Note that there are some explanatory texts on larger screens.

plurals
  1. POTwitter4j: OAuth Consumer Key/Secret Not Set
    primarykey
    data
    text
    <p>I've just started using Twitter4j and am trying to get my first application working. I've registered my application on the Twitter applications page and entered OAuth information into the twitter4j.properties file. However, every time I try to run the application I get an error message saying 'OAuth Consumer Key/Secret Not Set'. I've included the code with this message.</p> <p>Any help would be greatly appreciated.</p> <p>Thanks in advance, Aonghus</p> <pre><code>import java.util.logging.Logger; import twitter4j.Query; import twitter4j.QueryResult; import twitter4j.Status; import twitter4j.Tweet; import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; import twitter4j.auth.AccessToken; import twitter4j.auth.RequestToken; public class test { private final Logger logger = Logger.getLogger(test.class.getName()); public static void main(String[] args) { new test().publish(); } private void publish(){ String message="Twitter application using Java http://www.java-tutorial.ch/architecture/twitter-with-java-tutorial"; try { Twitter twitter = new TwitterFactory().getInstance(); try { RequestToken requestToken = twitter.getOAuthRequestToken(); AccessToken accessToken = null; while (null == accessToken) { logger.fine("Open the following URL and grant access to your account:"); logger.fine(requestToken.getAuthorizationURL()); try { accessToken = twitter.getOAuthAccessToken(requestToken); } catch (TwitterException te) { if (401 == te.getStatusCode()) { logger.severe("Unable to get the access token."); } else { te.printStackTrace(); } } } logger.info("Got access token."); logger.info("Access token: " + accessToken.getToken()); logger.info("Access token secret: " + accessToken.getTokenSecret()); } catch (IllegalStateException ie) { // access token is already available, or consumer key/secret is not set. if (!twitter.getAuthorization().isEnabled()) { logger.severe("OAuth consumer key/secret is not set."); return; } } Status status = twitter.updateStatus(message); logger.info("Successfully updated the status to [" + status.getText() + "]."); } catch (TwitterException te) { te.printStackTrace(); logger.severe("Failed to get timeline: " + te.getMessage()); } } } </code></pre>
    singulars
    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.
 

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