title: CURL in android
body: <p>I was looking through different blogs, sites and stack overflow for my answer. I have an app which shares images with a server. They provide a API token for the authentication, and the authentication is using curl. Can any one tell me how can I use curl in my app. I have to pass url as <code>API token + password+ the path</code> in the same form to get authentication. Can any one suggest some tricks to get it done.?</p>
  
  <p>Thanks in advance</p>
  
  <p>Happy Coding</p>
  
  <hr>
  
  <p><strong>Edit</strong></p>
  
  <p><strong>Code</strong></p>
  
  <pre><code> public static String getRequest() {
          StringBuffer stringBuffer = new StringBuffer("");
          BufferedReader bufferedReader = null;
          try {
              HttpClient httpClient = new DefaultHttpClient();
              HttpGet httpGet = new HttpGet();
  
              URI uri = new URI("http://s1.campfirenow.com/room/5e1a1/speak.xml");
              httpGet.setURI(uri);
              httpGet.addHeader(BasicScheme.authenticate(
                      new UsernamePasswordCredentials("f48be786f212f1e35dd9s265b4675358123d838e53", "X"),
                      HTTP.UTF_8, false));
  
              httpGet.setHeader("Content-Type", "application/xml");
              HttpResponse httpResponse = httpClient.execute(httpGet);
  </code></pre>
  
  <p>This is the log cat response from the server (<strong>logcat output</strong>) </p>
  
  <pre><code>05-05 09:34:29.180: INFO/global(7283): Loaded time zone names for en_US in 7701ms.
  05-05 09:34:29.230: DEBUG/dalvikvm(7283): GC_CONCURRENT freed 376K, 50% free 3080K/6087K, external 1357K/1828K, paused 6ms+6ms
  05-05 09:34:30.750: DEBUG/dalvikvm(7283): GC_CONCURRENT freed 687K, 52% free 3059K/6343K, external 1357K/1828K, paused 7ms+6ms
  05-05 09:34:31.470: DEBUG/dalvikvm(297): GC_EXPLICIT freed 10K, 55% free 2589K/5703K, external 716K/1038K, paused 115ms
  05-05 09:34:31.851: INFO/server responce(7283): &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  05-05 09:34:31.851: INFO/server responce(7283):        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;head&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;meta http-equiv="content-type" content="text/html;charset=utf-8" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;meta name="robots" content="noindex,nofollow" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;title&gt;Campfire: Sign in&lt;/title&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;link href="/stylesheets/screen.css?1304413304" media="all" rel="stylesheet" type="text/css" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;link href="/stylesheets/backpack-styles-for-login.css?1304413304" media="all" rel="stylesheet" type="text/css" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;script src="/sprockets.js?1304413286" type="text/javascript"&gt;&lt;/script&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;meta name="queenbee-id" content="1515015" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;meta name="return-to-location" content="" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;/head&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;body class="modal login "&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;div id="Container"&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;div id="Modal"&gt;    
  05-05 09:34:31.851: INFO/server responce(7283):     &lt;div class="inner"&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       
  05-05 09:34:31.851: INFO/server responce(7283):       
  05-05 09:34:31.851: INFO/server responce(7283):       
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;a href="http://www.campfirenow.com" class="logo_link"&gt;&lt;img alt="Campfire Logo" height="98" id="logo" src="/images/logo.png?1304413304" width="96" /&gt;&lt;/a&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       
  05-05 09:34:31.851: INFO/server responce(7283): &lt;div id="login_dialog" class="login_dialog"&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;form action="https://launchpad.37signals.com/authenticate" method="post"&gt;&lt;div style="margin:0;padding:0;display:inline"&gt;&lt;input name="authenticity_token" type="hidden" value="QKfiIN4bccN8ch86vb6mcDneEec+B9iYp2/3AewQLs4=" /&gt;&lt;/div&gt;
  05-05 09:34:31.851: INFO/server responce(7283):     &lt;input id="product" name="product" type="hidden" value="campfire" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):     &lt;input id="subdomain" name="subdomain" type="hidden" value="s1" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):     &lt;div id="user_name_login"&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;h2&gt;Username&lt;/h2&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;input autocapitalize="off" autocorrect="off" id="username" name="username" type="text" /&gt;&lt;br/&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;h2&gt;Password&lt;/h2&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;input id="password" name="password" type="password" /&gt;&lt;br/&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;label&gt;&lt;input class="auto" id="remember_me" name="remember_me" type="checkbox" value="1" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):         Remember me on this computer
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;/label&gt;&lt;br /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;input class="button" name="commit" type="submit" value="Sign in" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;div class="extras"&gt;
  05-05 09:34:31.851: INFO/server responce(7283):         &lt;ul&gt;
  05-05 09:34:31.851: INFO/server responce(7283):           &lt;li&gt;&lt;strong&gt;Help:&lt;/strong&gt; &lt;a href="https://s1.campfirenow.com/forgot_password"&gt;I forgot my username or password&lt;/a&gt;&lt;/li&gt;
  05-05 09:34:31.851: INFO/server responce(7283):           &lt;li&gt;&lt;a href="#" onclick="Login.loginWithOpenId(); return false;"&gt;Sign in using an OpenID instead&lt;/a&gt;&lt;/li&gt;
  05-05 09:34:31.851: INFO/server responce(7283):         &lt;/ul&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;/div&gt;
  05-05 09:34:31.851: INFO/server responce(7283):     &lt;/div&gt;
  05-05 09:34:31.851: INFO/server responce(7283):     &lt;div id="open_id_login" style="display: none"&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;h2&gt;&lt;img src="/images/openid-logo.png" alt="Sign in with an OpenID" /&gt;&lt;/h2&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;input autocapitalize="off" autocorrect="off" id="openid_identifier" name="openid_identifier" type="text" /&gt;&lt;br/&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;label&gt;&lt;input class="auto" id="remember_me" name="remember_me" type="checkbox" value="1" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):         Remember me on this computer
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;/label&gt;&lt;br /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;input class="button" name="commit" type="submit" value="Sign in" /&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;div class="extras"&gt;
  05-05 09:34:31.851: INFO/server responce(7283):         &lt;ul&gt;
  05-05 09:34:31.851: INFO/server responce(7283):           &lt;li&gt;&lt;strong&gt;Help:&lt;/strong&gt; &lt;a href="/authentication/open_id_alternative"&gt;My OpenID isn't working and I can't sign in&lt;/a&gt;&lt;/li&gt;
  05-05 09:34:31.851: INFO/server responce(7283):           &lt;li&gt;&lt;a href="#" onclick="Login.loginWithUserName(); return false;"&gt;Sign in using a standard username/password&lt;/a&gt;&lt;/li&gt;
  05-05 09:34:31.851: INFO/server responce(7283):         &lt;/ul&gt;
  05-05 09:34:31.851: INFO/server responce(7283):       &lt;/div&gt;
  05-05 09:34:31.851: INFO/server responce(7283):     &lt;/div&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;/form&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;/div&gt;
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;script type="text/javascript"&gt;
  05-05 09:34:31.851: INFO/server responce(7283): //&lt;![CDATA[
  05-05 09:34:31.851: INFO/server responce(7283): Login.loginWithUserName({"animate":false})
  05-05 09:34:31.851: INFO/server responce(7283): //]]&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;/script&gt;
  05-05 09:34:31.851: INFO/server responce(7283):     &lt;/div&gt;    
  05-05 09:34:31.851: INFO/server responce(7283):   &lt;/div&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;/div&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;/body&gt;
  05-05 09:34:31.851: INFO/server responce(7283): &lt;/html&gt;
  05-05 09:34:31.921: DEBUG/dalvikvm(7283): GC_CONCURRENT freed 479K, 51% free 3158K/6343K, external 1357K/1828K, paused 6ms+9ms
  </code></pre>