我目前正在观看 android 教程的视频 10 ( http://marakana.com/s/post/1046/threading_android_demo ),我正在努力让状态更新正常工作。
当我使用 JTwitter-yamba 库时,如果我得到一个 301 异常,说“301(永久移动)”
它实际上能够发布状态,但在那之后很快就崩溃了。
从这个 stackoverflow 看来,使用更新的 JTwitter 库应该可以修复它: Authorization error with jTwitter for android
当我使用最新的 JTwitter 库 (2.8.8) 时,我收到以下错误:“HTTP\1.1 错误请求”
我也得到:
[06-23 00:05:13.244: E/AndroidRuntime(3329): {"error":"客户端必须提供一个带有值的 'status' 参数。","request":"/api/statuses/update.json "} http://yamba.marakana.com/api/statuses/update.json ]
我不确定该怎么做..
任何帮助表示赞赏。
福阿德。
我正在使用的 StatusActivity.java 代码:
package com.example.yamba;
import winterwell.jtwitter.Twitter;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
public class StatusActivity extends Activity {
EditText editStatus;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.status); //
editStatus = (EditText) findViewById(R.id.edit_status);
}
public void onClick(View v) {
final String statusText = editStatus.getText().toString();
new Thread() {
@Override
public void run() {
Twitter twitter = new Twitter("student", "password");
twitter.setAPIRootUrl("http://yamba.marakana.com/api"); // redirecting
twitter.setStatus(statusText);
Log.d("StatusActivity", statusText);
}
}.start();
Log.d("StatusActivity", "Reached this point");
}
}
我得到的 logcat 错误:
06-23 15:20:46.898: W/dalvikvm(28815): threadid=11: thread exiting with uncaught exception (group=0x41b91540)
06-23 15:20:46.898: E/AndroidRuntime(28815): FATAL EXCEPTION: Thread-8268
06-23 15:20:46.898: E/AndroidRuntime(28815): winterwell.jtwitter.TwitterException: 400 Bad Request
06-23 15:20:46.898: E/AndroidRuntime(28815): HTTP/1.1 400 Bad Request
06-23 15:20:46.898: E/AndroidRuntime(28815): {"error":"Too many duplicate messages too quickly; take a breather and post again in a few minutes.","request":"\/api\/statuses\/update.json"} http://yamba.marakana.com/api/statuses/update.json
06-23 15:20:46.898: E/AndroidRuntime(28815): at winterwell.jtwitter.URLConnectionHttpClient.processError(URLConnectionHttpClient.java:517)
06-23 15:20:46.898: E/AndroidRuntime(28815): at winterwell.jtwitter.URLConnectionHttpClient.post2_connect(URLConnectionHttpClient.java:412)
06-23 15:20:46.898: E/AndroidRuntime(28815): at winterwell.jtwitter.URLConnectionHttpClient.post2(URLConnectionHttpClient.java:378)
06-23 15:20:46.898: E/AndroidRuntime(28815): at winterwell.jtwitter.URLConnectionHttpClient.post(URLConnectionHttpClient.java:347)
06-23 15:20:46.898: E/AndroidRuntime(28815): at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:2762)
06-23 15:20:46.898: E/AndroidRuntime(28815): at winterwell.jtwitter.Twitter.updateStatus(Twitter.java:2694)
06-23 15:20:46.898: E/AndroidRuntime(28815): at winterwell.jtwitter.Twitter.setStatus(Twitter.java:2482)
06-23 15:20:46.898: E/AndroidRuntime(28815): at com.example.yamba.StatusActivity$1.run(StatusActivity.java:31)