Http Basic Authentication

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Http Basic Authentication

Postby adilfulara » Sun Jun 22, 2008 8:14 am

Hi,

I was trying to perform basic authentication with twitter api and i was getting mixed responses.

On first attempt this after noon, i got 200 status message and i thought i should move on ahead to parsing the xml response.

But this evening i retried it again and get messages 400 and 401.

The following is the code i have written.

I did see Http Post Tutorial but could not find the specific packages in the docs and instead wrote the following using the api doc.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.                 HttpClient client = new HttpClient();
  3.  
  4.                 client.getParams().setParameter("http.useragent", "android Client");
  5.  
  6.                 GetMethod method = new GetMethod(twitter_statustime_url);
  7.  
  8.                 NameValuePair nvp1 = new NameValuePair("username",name);
  9.  
  10.                 NameValuePair nvp2 = new NameValuePair("password",passw);
  11.  
  12.                 method.setQueryString(new NameValuePair[]{nvp1,nvp2});
  13.  
  14.                 method.setDoAuthentication(true);
  15.  
  16.                
  17.  
  18.                 int result=0;
  19.  
  20.                 try {
  21.  
  22.                         result = client.executeMethod(method);
  23.  
  24.                 } catch (HttpException e) {
  25.  
  26.                         Toast.makeText(TwitterAppMain.this,
  27.  
  28.                                         "Result code " + e.getMessage(), 4000).show();
  29.  
  30.                 } catch (IOException e) {
  31.  
  32.                         Toast.makeText(TwitterAppMain.this,
  33.  
  34.                                         "Result code " + e.getMessage(), 4000).show();
  35.  
  36.                 }
  37.  
  38.                 Toast.makeText(TwitterAppMain.this,
  39.  
  40.                                         "Result code " + e.getMessage(), 4000).show();
  41.  
  42.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Any help would be appreciated.

Thank you.

~Adil
adilfulara
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jun 21, 2008 10:31 pm

Top

Postby coding_android » Sun Jul 20, 2008 4:42 pm

I got the same problem. Could someone help us? Would be really nice!

Regards!
User avatar
coding_android
Moderator
Moderator
 
Posts: 76
Joined: Mon May 05, 2008 10:22 am
Location: Germany

Postby adalgiso » Wed Sep 10, 2008 8:26 pm

Bumping because I am working on a Twitter application for a class project :D .
adalgiso
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Sep 10, 2008 4:09 am
Location: Clemson University

Postby ninor » Thu Sep 11, 2008 1:47 am

Could you try using another http-client string? Maybe ripping one from Firefox, or IExplorer
Some times I had difficulties programming .NET apps that access RSS feeds, but only for this reason: the http-client name.

Hope this helps
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 6 guests