twitter4j 3.0.3 - 更新状态错误404 - 仅在生产中发生

时间:2013-12-04 08:44:52

标签: java twitter twitter4j

使用twitter4j 3.0.3通过Web应用程序更新Twitter状态时出现了一个奇怪的错误。

我的应用程序可以在dev环境中运行时成功更新状态。但在我将应用程序部署并运行到生产环境后,它无法更新任何状态。

应用程序应该是相同的。我不确定我的生产环境中是否存在网络问题。或者也许twitter只能从一台机器(dev)中只授权一个应用程序并将其锁定用于其他机器(prod)?

我所知道的是它给出了以下错误信息:

2013-12-04 06:18:39 ERROR TwitterServiceImpl:68 - 404:The URI requested is invalid or the resource requested, such as a user, does not exists. Also returned when the requested format is not supported by the requested method.
<html><head><title>Apache Tomcat/7.0.40 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /1.1/statuses/update.json</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/1.1/statuses/update.json</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.40</h3></body></html>

Relevant discussions can be found on the Internet at:
    http://www.google.co.jp/search?q=b2b52c28 or
    http://www.google.co.jp/search?q=10981ab8
TwitterException{exceptionCode=[b2b52c28-10981ab8], statusCode=404, message=null, code=-1, retryAfter=-1, rateLimitStatus=null, version=3.0.3}

我在dev.twitter.com上创建了应用程序,并设置了对“读取,写入和访问直接消息”的访问。我还使用应用程序详细信息页面中提供的Consumer密钥,Consumer secret,Access token和Access token secret。

这是我在java中的代码:

@Override
public void updateStatus(String message) throws BusinessException {
    try {
        ConfigurationBuilder confbuilder  = new ConfigurationBuilder();
        confbuilder.setOAuthAccessToken(TWITTER_ACCESS_TOKEN)
        .setOAuthAccessTokenSecret(TWITTER_ACCESS_TOKEN_SECRET)
        .setOAuthConsumerKey(TWITTER_CONSUMER_KEY)
        .setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
        Twitter twitter = new TwitterFactory(confbuilder.build()).getInstance();

        Status status = twitter.updateStatus(message);
        logger.info("Successfully updated the status to [" + status.getText() + "].");
    } catch (Exception e) {
        logger.error(e);
        throw new BusinessException(e.getMessage());
    }
}

任何想法的人?

1 个答案:

答案 0 :(得分:0)

确保您已正确输入密钥,时间戳为UTC,距离我们的时间只有几分钟。