简体   繁体   English

Twiiter4J getDirectMessages()不再起作用了吗?

[英]Twiiter4J getDirectMessages() does not work anymore?

I am using Twitter4J 2.2.5 (latest, tried other versions). 我正在使用Twitter4J 2.2.5(最新的,尝试过其他版本)。 And can no longer get direct messages to work at all. 而且根本无法获得直接的消息。 The same code used to work a while ago. 以前使用过的相同代码。 I assume Twitter changed something. 我认为Twitter有所改变。

I'm using 我正在使用

Twitter.getDirectMessages() Twitter.getDirectMessages()

and it gives the error below. 并给出以下错误。 No idea why, I can see the direct messages for the account if I login, but always get this error. 不知道为什么,如果登录,我可以看到该帐户的直接消息,但总是会收到此错误。 The limit error makes no sense, as the account is no where near the limit. 限制错误是没有意义的,因为帐户在限制附近。

Other API work, like followers/fried/status/etc. 其他API工作,例如followers / fried / status / etc。

403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (http://support.twitter.com/forums/10711/entries/15364).
Relevant discussions can be on the Internet at:
    http://www.google.co.jp/search?q=00919618 or
    http://www.google.co.jp/search?q=332bf6ca
TwitterException{exceptionCode=[00919618-332bf6ca], statusCode=403, retryAfter=0, rateLimitStatus=RateLimitStatusJSONImpl{remainingHits=107, hourlyLimit=350, resetTimeInSeconds=1328297, secondsUntilReset=1116, resetTime=Fri Feb 03 14:39:45 EST 2012}, version=2.2.2}
    at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:189)
    at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
    at twitter4j.internal.http.HttpClientWrapper.get(HttpClientWrapper.java:93)
    at twitter4j.TwitterImpl.get(TwitterImpl.java:1721)
    at twitter4j.TwitterImpl.getDirectMessages(TwitterImpl.java:874)
    at org.pandora.sense.twitter.TwitterDirectMessaging.checkDirectMessages(TwitterDirectMessaging.java:44)
    at org.pandora.sense.twitter.TwitterDirectMessaging.checkProfile(TwitterDirectMessaging.java:35)
    at org.pandora.sense.twitter.Twitter$1.run(Twitter.java:100)
    at java.lang.Thread.run(Thread.java:662)

Twitter has some time ago changed the rules for direct messages. Twitter不久前更改了直接消息的规则。 An app must be especially authorized by the user to access the direct messages. 应用必须得到用户的特别授权才能访问直接消息。

Did you make sure this is true for you? 您确定这对您来说是对的吗? You may go to the twitter web site and check for the app. 您可以访问Twitter网站并检查该应用程序。

To get the direct message you should try the below code.It works for me. 要获得直接消息,您应该尝试以下代码。它对我有用。

getDirectMessages(); getDirectMessages(); gives list of direct messages. 给出直接消息列表 We need to put for loop to get text of each message. 我们需要放置for循环以获取每个消息的文本。

      List<DirectMessage> messages = twitter.getDirectMessages();
      for (DirectMessage message : messages) 
      {
          System.out.println(message.getText());
      }

Let me know if you get any error. 让我知道您是否遇到任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM