Sina Weibo Android SDK-how to print 5-Bit Error Codes

Source: Internet
Author: User

Sina Weibo was first written into the project and used its Java SDK. However, I recently sorted out various sdks and found that Sina Weibo requires oauth2.0 for new applications, so I can only use its Android SDK to re-write it to the program. In fact, the rewrite program is relatively simple, as long as it is modified according to its sample program. However, this process encountered a problem.

Problem description: after obtaining the access token, the image and text Weibo are sent, but each time only the first message is sent successfully, the log information is obtained: "{" created_at ": "wed Mar 21 11:12:52 + 0800 ......". However, if I continue to send the message, the message "com.weibo.net. weiboexception:
HTTP/1.1 400 ". I asked on the Sina Forum that the moderator asked me to provide five error codes. I am confused. Do I need to capture packets...

Problem solving: in fact, we will find that the log information we get twice is actually different. At least the second time should also be: "{…}" . So I suspect it is an internal error in the SDK. After my debugging, our final solution is:

In the SDK's utility. Java line 335th: Throw new weiboexception (string. Format (status. tostring ()),
Statuscode );
Change: Throw new weiboexception (result, statuscode); it is estimated that the author made a mistake in writing.



Then, output the error message in your program:

weiboRunner.request(AAuthTestActivity.this, url, bundle, Utility.HTTPMETHOD_POST, new  com.weibo.net.AsyncWeiboRunner.RequestListener(){                          @Override                         public void onComplete(String arg0) {                             // TODO Auto-generated method stub                             Log.e("sina_complete",arg0.toString());                         }                          @Override                         public void onError(WeiboException arg0) {                             // TODO Auto-generated method stub                             Log.e("sina_error",arg0.toString());                         }                          @Override                         public void onIOException(IOException arg0) {                             // TODO Auto-generated method stub                             Log.e("sina_IOException",arg0.toString());                         }                                              });

My output information is: {"error": "Repeat content! "," Error_code ": 20019," request ":"/2/statuses/upload. JSON "}. So that you can find the cause of your error in the http://open.weibo.com/wiki/Help/error.

Hope to help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.