使用java在twitter墙上发布消息

时间:2014-09-03 12:25:15

标签: java twitter struts2

我创建了Twitter API密钥,密钥,访问令牌,访问令牌密钥...然后我试图通过使用java在twitter墙上发布简单文本...我使用了twitter4j API ...但它工作不正常..我运行程序时出现此错误。“** 401:身份验证凭据(https://dev.twitter.com/pages/auth)丢失或不正确。确保您设置了有效的消费者密钥/密钥,访问令牌/ secret,系统时钟同步。**“....我的代码是......

    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 个答案:

没有答案