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!