title: Twitter + OAuth Integration
body: <p>Anybody can please help in Android + Twitter Integration using OAuth.</p>
  
  <p>I already worked on <a href="http://github.com/brione/Brion-Learns-OAuth" rel="nofollow noreferrer">http://github.com/brione/Brion-Learns-OAuth</a> and getting the error listed below, when I am posting status update...</p>
  
  <pre><code>WARN/System.err(190): org.apache.http.client.HttpResponseException: Unauthorized
  WARN/System.err(190):     at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:71)
  WARN/System.err(190):     at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:59)
  WARN/System.err(190):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
  WARN/System.err(190):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
  WARN/System.err(190):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
  WARN/System.err(190):     at com.test.twitter.BLOA$PostTask.doInBackground(BLOA.java:343)
  WARN/System.err(190):     at com.test.twitter.BLOA$PostTask.doInBackground(BLOA.java:1)
  WARN/System.err(190):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
  WARN/System.err(190):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:256)
  WARN/System.err(190):     at java.util.concurrent.FutureTask.run(FutureTask.java:122)
  WARN/System.err(190):     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:648)
  WARN/System.err(190):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:673)
  WARN/System.err(190):     at java.lang.Thread.run(Thread.java:1060)
  </code></pre>
  
  <p>I succeed with OAuth Authentication and getting user_secret and user_token and stored in preferences...</p>
  
  <p>So the issue is with http posting using OAuth header... </p>
  
  <p>and My Http Post Method is as :</p>
  
  <pre><code>private class PostTask extends AsyncTask&lt;String, Void, JSONObject&gt; {
  
    ProgressDialog postDialog;
  
    @Override
    protected void onPreExecute() {
     postDialog = ProgressDialog.show(BLOA.this,
       getText(R.string.tweet_progress_title),
       getText(R.string.tweet_progress_text), true, // indeterminate
                   // duration
       false); // not cancel-able
    }
  
    @Override
    protected JSONObject doInBackground(String... params) {
  
     JSONObject jso = null;
     try {
      HttpPost post = new HttpPost(
        "http://twitter.com/statuses/update.json");
      LinkedList&lt;BasicNameValuePair&gt; out = new LinkedList&lt;BasicNameValuePair&gt;();
      out.add(new BasicNameValuePair("status", params[0]));
      post.setEntity(new UrlEncodedFormEntity(out, HTTP.UTF_8));
      post.setParams(getParams());
      // sign the request to authenticate
      mConsumer.sign(post);
      String response = mClient.execute(post,
        new BasicResponseHandler());
      jso = new JSONObject(response);
     } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
     } catch (OAuthMessageSignerException e) {
      e.printStackTrace();
     } catch (OAuthExpectationFailedException e) {
      e.printStackTrace();
     } catch (OAuthCommunicationException e) {
      e.printStackTrace();
     } catch (ClientProtocolException e) {
      e.printStackTrace();
     } catch (IOException e) {
      e.printStackTrace();
     } catch (JSONException e) {
      e.printStackTrace();
     } finally {
  
     }
     return jso;
    }
  
    // This is in the UI thread, so we can mess with the UI
    protected void onPostExecute(JSONObject jso) {
     postDialog.dismiss();
     if (jso != null) { // authorization succeeded, the json object
       // contains the user information
      mEditor.setText("");
      mLast.setText(getCurrentTweet(jso));
     } else {
      mLast.setText(getText(R.string.tweet_error));
     }
    }
   }
  </code></pre>