Android Twitter4j 在转发或发送消息时出现错误

发布于 2024-11-30 10:38:20 字数 4741 浏览 1 评论 0原文

我正在使用 Twitter4j API 制作一个用于 Twitter 集成的应用程序。

现在我的问题是, 当我尝试转发或发送直接消息时,例如:

twitter.retweetStatus(sid); twitter.sendDirectMessage(uid, msg);

我收到以下错误:

> 08-20 11:11:17.409: WARN/System.err(233): 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). 08-20
> 11:11:17.409: WARN/System.err(233): Relevant discussions can be on the
> Internet at: 08-20 11:11:17.409: WARN/System.err(233):    
> http://www.google.co.jp/search?q=dbd7edaf or 08-20 11:11:17.409:
> WARN/System.err(233):     http://www.google.co.jp/search?q=012e63a7
> 08-20 11:11:17.409: WARN/System.err(233):
> TwitterException{exceptionCode=[dbd7edaf-012e63a7], statusCode=403,
> retryAfter=0, rateLimitStatus=null, version=2.1.11} 08-20
> 11:11:17.409: WARN/System.err(233):     at
> twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:199)
> 08-20 11:11:17.419: WARN/System.err(233):     at
> twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:75)
> 08-20 11:11:17.419: WARN/System.err(233):     at
> twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:128)
> 08-20 11:11:17.419: WARN/System.err(233):     at
> twitter4j.Twitter.retweetStatus(Twitter.java:661) 08-20 11:11:17.419:
> WARN/System.err(233):     at
> com.openxcell.zoodig.TimelineRe$3.onClick(TimelineRe.java:98) 08-20
> 11:11:17.419: WARN/System.err(233):     at
> android.view.View.performClick(View.java:2344) 08-20 11:11:17.419:
> WARN/System.err(233):     at
> android.view.View.onTouchEvent(View.java:4133) 08-20 11:11:17.419:
> WARN/System.err(233):     at
> android.widget.TextView.onTouchEvent(TextView.java:6510) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.View.dispatchTouchEvent(View.java:3672) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.439: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.439: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.439: WARN/System.err(233):     at
> com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712)
> 08-20 11:11:17.439: WARN/System.err(233):     at
> com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1202)
> 08-20 11:11:17.439: WARN/System.err(233):     at
> android.app.Activity.dispatchTouchEvent(Activity.java:1987) 08-20
> 11:11:17.439: WARN/System.err(233):     at
> com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1696)
> 08-20 11:11:17.439: WARN/System.err(233):     at
> android.view.ViewRoot.handleMessage(ViewRoot.java:1658) 08-20
> 11:11:17.449: WARN/System.err(233):     at
> android.os.Handler.dispatchMessage(Handler.java:99) 08-20
> 11:11:17.449: WARN/System.err(233):     at
> android.os.Looper.loop(Looper.java:123) 08-20 11:11:17.449:
> WARN/System.err(233):     at
> android.app.ActivityThread.main(ActivityThread.java:4203) 08-20
> 11:11:17.449: WARN/System.err(233):     at
> java.lang.reflect.Method.invokeNative(Native Method) 08-20
> 11:11:17.449: WARN/System.err(233):     at
> java.lang.reflect.Method.invoke(Method.java:521) 08-20 11:11:17.459:
> WARN/System.err(233):     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
> 08-20 11:11:17.470: WARN/System.err(233):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 08-20
> 11:11:17.470: WARN/System.err(233):     at
> dalvik.system.NativeStart.main(Native Method)

任何人都可以告诉我为什么会收到此错误吗? api有什么问题吗? 或者我在哪里犯错了?

任何有关此问题的帮助将不胜感激..

谢谢, 马尤尔·帕雷克

I am making an app for twitter integration using Twitter4j API.

Right now my problem is,
when i tried to make retweet or send direct messages like:

twitter.retweetStatus(sid);
twitter.sendDirectMessage(uid, msg);

i got the following error:

> 08-20 11:11:17.409: WARN/System.err(233): 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). 08-20
> 11:11:17.409: WARN/System.err(233): Relevant discussions can be on the
> Internet at: 08-20 11:11:17.409: WARN/System.err(233):    
> http://www.google.co.jp/search?q=dbd7edaf or 08-20 11:11:17.409:
> WARN/System.err(233):     http://www.google.co.jp/search?q=012e63a7
> 08-20 11:11:17.409: WARN/System.err(233):
> TwitterException{exceptionCode=[dbd7edaf-012e63a7], statusCode=403,
> retryAfter=0, rateLimitStatus=null, version=2.1.11} 08-20
> 11:11:17.409: WARN/System.err(233):     at
> twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:199)
> 08-20 11:11:17.419: WARN/System.err(233):     at
> twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:75)
> 08-20 11:11:17.419: WARN/System.err(233):     at
> twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:128)
> 08-20 11:11:17.419: WARN/System.err(233):     at
> twitter4j.Twitter.retweetStatus(Twitter.java:661) 08-20 11:11:17.419:
> WARN/System.err(233):     at
> com.openxcell.zoodig.TimelineRe$3.onClick(TimelineRe.java:98) 08-20
> 11:11:17.419: WARN/System.err(233):     at
> android.view.View.performClick(View.java:2344) 08-20 11:11:17.419:
> WARN/System.err(233):     at
> android.view.View.onTouchEvent(View.java:4133) 08-20 11:11:17.419:
> WARN/System.err(233):     at
> android.widget.TextView.onTouchEvent(TextView.java:6510) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.View.dispatchTouchEvent(View.java:3672) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.429: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.439: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.439: WARN/System.err(233):     at
> android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:882) 08-20
> 11:11:17.439: WARN/System.err(233):     at
> com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1712)
> 08-20 11:11:17.439: WARN/System.err(233):     at
> com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1202)
> 08-20 11:11:17.439: WARN/System.err(233):     at
> android.app.Activity.dispatchTouchEvent(Activity.java:1987) 08-20
> 11:11:17.439: WARN/System.err(233):     at
> com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1696)
> 08-20 11:11:17.439: WARN/System.err(233):     at
> android.view.ViewRoot.handleMessage(ViewRoot.java:1658) 08-20
> 11:11:17.449: WARN/System.err(233):     at
> android.os.Handler.dispatchMessage(Handler.java:99) 08-20
> 11:11:17.449: WARN/System.err(233):     at
> android.os.Looper.loop(Looper.java:123) 08-20 11:11:17.449:
> WARN/System.err(233):     at
> android.app.ActivityThread.main(ActivityThread.java:4203) 08-20
> 11:11:17.449: WARN/System.err(233):     at
> java.lang.reflect.Method.invokeNative(Native Method) 08-20
> 11:11:17.449: WARN/System.err(233):     at
> java.lang.reflect.Method.invoke(Method.java:521) 08-20 11:11:17.459:
> WARN/System.err(233):     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
> 08-20 11:11:17.470: WARN/System.err(233):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) 08-20
> 11:11:17.470: WARN/System.err(233):     at
> dalvik.system.NativeStart.main(Native Method)

Can anyone please tell me why i am getting this?
is there anything problem with api?
or where i am making mistake?

Any Help Regarding this will be Appreciated..

Thank You,
Mayur Parekh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋凉 2024-12-07 10:38:20

您提供的堆栈跟踪包含一条消息,告诉您发生了什么。

从堆栈跟踪:

403:请求已被理解,但已被拒绝。一个
随附的错误消息将解释原因。该代码在以下情况下使用
由于更新限制,请求被拒绝
http://support.twitter.com/forums/10711/entries/15364)

中提供的 链接消息表明存在一些 API 限制。以下是该页面的消息:

限制减轻了 Twitter 幕后部分的压力,并减少了停机时间和错误页面。为了可靠性,我们对帐户操作设置了一些限制,例如关注、API 请求、私信和更新。

以下是各种限制的详细信息:

  1. 私信:每天 250 条
  2. 更新:每天 1,000 次。每日更新限制进一步细分为每半小时间隔的较小限制。转发算作更新。
  3. 帐户电子邮件更改:每小时 4 次
  4. 关注(每日):请注意,这只是技术帐户限制,还有其他规则禁止激进的关注行为。您可以在遵循限制和最佳实践页面上找到描述以下限制和禁止行为的详细页面。技术关注限制为每天 1,000
  5. 关注(基于帐户):一旦帐户关注了 2,000 个其他用户,额外的关注尝试就会受到特定于帐户的比率的限制。遵循限制和最佳实践页面提供了更多信息。

The stacktrace that you have provided contains a message which tells you what happened.

From the stacktrace:

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)

The link provided in the message suggests that there are some API limits. Here is the message from the page:

Limits alleviate some of the strain on the behind-the-scenes part of Twitter, and reduce downtime and error pages. For the sake of reliability, we've placed some limits on account actions like following, API requests, direct messages, and updates.

Here is the breakdown of the various limits:

  1. Direct Messages: 250 per day.
  2. Updates: 1,000 per day. The daily update limit is further broken down into smaller limits for semi-hourly intervals. Retweets are counted as updates.
  3. Changes to Account Email: 4 per hour.
  4. Following (daily): Please note that this is a technical account limit only, and there are additional rules prohibiting aggressive following behavior. You can find detailed page describing following limits and prohibited behavior on the Follow Limits and Best Practices Page. The technical follow limit is 1,000 per day.
  5. Following (account-based): Once an account is following 2,000 other users, additional follow attempts are limited by account-specific ratios. The Follow Limits and Best Practices Page has more information.
泡沫很甜 2024-12-07 10:38:20

就我而言,我收到此错误是因为响应不仅仅是一个JSON对象,而是是一个 JSON数组 我试图将其直接转换为 JSONObject。

所以错误现在已解决。

谢谢@nicholas,你的回答帮助了我很多。

in my case i was getting this error cause the response was not just a JSON Object but that was a JSON Array and i was trying to conver it into JSONObject directly..

So the error is resolved now.

Thank You @nicholas your answer helped me alot..

清泪尽 2024-12-07 10:38:20

最近我在执行类似的代码时遇到了同样的错误。要修复此问题,请按照以下步骤操作:

  • 转到 https://apps.twitter.com/app/your_app_id
  • 单击密钥和访问令牌
  • 在访问级别中,单击修改应用程序权限并选择第三个选项:读取、写入和访问直接消息
  • 单击更新。 (注意:如果您没有在 Twitter 中添加手机号码,您可能需要添加您的手机号码并使用 otp 进行验证才能获得此访问权限
  • )秘密和访问令牌&使用可点击的按钮秘密

你就完成了!您的程序将开始运行。

Recently I got the same error while executing similar code. To fix it, follow these steps:

  • Go to https://apps.twitter.com/app/your_app_id
  • Click on Keys and access token
  • In Access Level, click modify app permission and choose the 3rd option: Read, Write and Access direct messages
  • Click on update. ( Note: you might have to add your mobile no and verify with otp to get this access if you don't have your no added in twitter)
  • Regenerate both Consumer key & secret and Access token & secret using the click-able button

And you are done! Your program will start working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文