0
@Override
protected Boolean doInBackground(Void... params) {
    // TODO Auto-generated method stub


        HttpClient httpclient = new DefaultHttpClient();  
        Log.d("HTTP","Exe");
        String sw=Sign(token);
        Log.d("HTTP","Exe");

        HttpPost httpPost;
        Log.d("HTTP","Exec");
        httpPost = new HttpPost(sw);
        Log.d("HTTP","Execute");

        HttpResponse response;
        try 
        {

            Log.d("HTTP","Executed");
//**THIS IS WHERE IT STOPS EXECUTION**

                response = httpclient.execute(httpPost); // the request executes
                Log.d("HTTP","Executed");
                HttpEntity entity = response.getEntity();
                InputStream is = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(is, "utf-8"), 256);
                StringBuilder sb = new StringBuilder();
                String line = null;
                while ((line = reader.readLine()) != null)  sb.append(line); 
                String result = sb.toString();
                is.close();
                Log.d("HTTP",result);
                String  responseBody = EntityUtils.toString(((HttpResponse) response).getEntity());
                retString=responseBody;
                Log.d("HTTP",result);

            } 

            catch (ClientProtocolException e) {
                    e.printStackTrace();
            }
            catch(ConnectTimeoutException e){
                    e.printStackTrace();
            }
            catch (IOException e) {
                    e.printStackTrace();
            }


            //return null;

        return null;
    }

私のLogCat:

06-25 23:45:59.105: D/HTTP(5993): wz27t6thob0fbxl
06-25 23:46:03.223: D/HTTP(5993): Exe
06-25 23:46:03.766: D/HTTP(5993): 1340648163
06-25 23:46:05.378: D/HTTP(5993): https://api.dropbox.com/1/shares/dropbox/a.jpg?oauth_consumer_key=2f2y1dyuqhp58ek&oauth_token=wz27t6thob0fbxl&oauth_nonce=1340648163&oauth_timestamp=1340648163&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_signature=bo%2F5zuowvX%2Fcjy5uPP5ZPjUiP64%3D%0A
06-25 23:46:05.402: D/HTTP(5993): Exe
06-25 23:46:05.402: D/HTTP(5993): Exec
06-25 23:46:06.132: D/HTTP(5993): Execute
06-25 23:46:09.363: D/HTTP(5993): Executed
06-25 23:46:38.742: D/dalvikvm(5993): GC_FOR_MALLOC freed 5331 objects / 305856 bytes in 400ms
06-25 23:46:51.413: D/HTTP(5993): Executed
06-25 23:46:51.952: D/HTTP(5993): {"error": "Invalid signature. Expected signature base string: POST&https%3A%2F%2Fapi.dropbox.com%2F1%2Fshares%2Fdropbox%2Fa.jpg&oauth_consumer_key%3D2f2y1dyuqhp58ek%26oauth_nonce%3D1340648163%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1340648163%26oauth_token%3Dwz27t6thob0fbxl%26oauth_version%3D1.0"}
06-25 23:47:49.032: W/dalvikvm(5993): threadid=7: thread exiting with uncaught exception (group=0x4001d800)
06-25 23:47:49.462: E/AndroidRuntime(5993): FATAL EXCEPTION: AsyncTask #1
06-25 23:47:49.462: E/AndroidRuntime(5993): java.lang.RuntimeException: An error occured while executing doInBackground()
06-25 23:47:49.462: E/AndroidRuntime(5993):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at java.lang.Thread.run(Thread.java:1096)
06-25 23:47:49.462: E/AndroidRuntime(5993): Caused by: java.lang.IllegalStateException: Content has been consumed
06-25 23:47:49.462: E/AndroidRuntime(5993):     at org.apache.http.entity.BasicHttpEntity.getContent(BasicHttpEntity.java:84)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at org.apache.http.conn.BasicManagedEntity.getContent(BasicManagedEntity.java:100)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at org.apache.http.util.EntityUtils.toString(EntityUtils.java:112)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at org.apache.http.util.EntityUtils.toString(EntityUtils.java:146)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at cloud.mobile.DropboxApi.doInBackground(DropboxApi.java:145)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at cloud.mobile.DropboxApi.doInBackground(DropboxApi.java:1)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-25 23:47:49.462: E/AndroidRuntime(5993):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-25 23:47:49.462: E/AndroidRuntime(5993):     ... 4 more

署名されたキー(sw)はhttps://api.dropbox.com/1/shares/dropbox/a.jpg?oauth_consumer_key=2f2y1dyuqhp58ek&oauth_token=wz27t6thob0fbxl&oauth_nonce=1340648163&oauth_timestamp=1340648163&oauth_signature_method=HMAC 3D%0A

http..の経験はあまりありません。

httpPost = new HttpPost(sw);なので 正常に動作しますが、それはベース文字列の署名が正しいことを意味しますか?

または私は何かが欠けていますか?

4

1 に答える 1

1

これは OAuth エラーとは関係ないようです。次のログ ステートメントに基づいて、http 投稿 URL にホストを設定していないようです。

Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters.
于 2012-06-25T18:11:58.527 に答える