82383

Android Twitter4j getting error while retweet or send message

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:

<strong>twitter.retweetStatus(sid); twitter.sendDirectMessage(uid, msg);</strong>

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

Answer1:

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:

<ol> <li>Direct Messages: <strong>250 per day</strong>.</li> <li>Updates: <strong>1,000 per day</strong>. The daily update limit is further broken down into smaller limits for semi-hourly intervals. Retweets are counted as updates.</li> <li>Changes to Account Email: <strong>4 per hour</strong>.</li> <li>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 <strong>1,000 per day</strong>.</li> <li>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.</li> </ol>

Answer2:

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 <strong>helped me</strong> alot..

Answer3:

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

    <li>Go to https://apps.twitter.com/app/your_app_id</li> <li>Click on Keys and access token</li> <li>In Access Level, click modify app permission and choose the 3rd option: Read, Write and Access direct messages</li> <li>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)</li> <li>Regenerate both Consumer key & secret and Access token & secret using the click-able button</li> </ul>

    And you are done! Your program will start working.

Recommend

  • cannot be cast to android.content.pm.PackageInfo on click in my listview
  • UknownHostException while trying to post a message to facebook
  • Pass data from class to activity
  • how to check if the click is Performclick or not
  • Android onInterceptTouchEvent, get childs in ViewGroup
  • Android Click button behind another button
  • How can I disable or specify the number of retries in HtmlUnit (java)?
  • Android: How to make my retrieved (from mysql) JSON parsed data added to ListView refresh it self ev
  • how to use subexpressions
  • Aliasing trait bounds without specifying concrete associated types
  • Json object integrate with android
  • Android json parse not working
  • TagException … null (File not found) on creating custom Facelets tag [duplicate]
  • Force Down error in MapView
  • Why does the address of an object change across methods?
  • Pipe in for loop breaks double quoted variables
  • Encoding issue with JLine
  • How to specify Data type in WSDL when exposed from CXF
  • Fancy dynamic list in Android: TableLayout vs ListView
  • Accessing Windows Azure Queues from client side javascript/jquery
  • Linux over commit heuristic
  • Why does .addView throw this parent/child exception?
  • How to Handle Click on Imageview in Custom Listview with image and Textview?
  • Complex trait requirements on struct
  • Null ImageView Reference
  • Are Richfaces and Primefaces compatible with each other?
  • Two Tables Serving as one Model in Rails
  • JqueryMobile Popup menu is not working
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • Spring Data JPA custom method causing PropertyReferenceException
  • Projection media query: browser support and workarounds?
  • Android screen density dpi vs ppi
  • Deselecting radio buttons while keeping the View Model in synch
  • Deleting and Updating values from a cusrsor adapter
  • Opengl-es onTouchEvents problem or a draw problem? [closed]
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • Cannot Parse HTML Data Using Android / JSOUP
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • Getting Messege Twice Using IMvxMessenger
  • How to load view controller without button in storyboard?