post message on twitter wall using java

2019-09-18 09:59发布

i was create twitter API key, secret key, access token, access token secret key... then i was tried to post simple text on twitter wall by using java... i was used twitter4j API for this... But its not working properly.. i got this error when i run my program.. "** 401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.**"....and my code is..

    static String consumerKeyStr = "";
    static String consumerSecretStr = "";
    static String accessTokenStr = "";
    static String accessTokenSecretStr = "";

    public String postSomething() throws Exception
    {
        Twitter twitter = new TwitterFactory().getInstance();

        twitter.setOAuthConsumer(consumerKeyStr, consumerSecretStr);
        AccessToken accessToken = new AccessToken(accessTokenStr,
                accessTokenSecretStr);

        twitter.setOAuthAccessToken(accessToken);

        twitter.updateStatus("Post using Twitter4J Again");

        System.out.println("Successfully updated the status in Twitter.");
        return "success";
    }

0条回答
登录 后发表回答