It looks like my example refuses to work with spreadsheets.google.com list
worksheet feed.
Here is the code snippet
authenticate() succeeds and I get the proper auth token.
However getWorksheetContents() fails with 404 Not found error.
I have double check the URL (worksheetsheetURL) using curl (it works fine on
curl), I have checked the tcpdump of both curl and my sample program -
nothing seems out of the place - but i am at loss to understand, why I am
getting 404 error.
Any Gdata gurus here who can help?? I am using this raw approach since there
is no gdata apis for android yet.
public void authenticate() {
HttpClient hClient = new DefaultHttpClient();
HttpPost hPost = new HttpPost("
https://www.google.com/accounts/ClientLogin");
List<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>(5);
nameValuePairs.add(new BasicNameValuePair("Email","
[email protected]"));
nameValuePairs.add(new BasicNameValuePair("Passwd","xxxxxx"));
nameValuePairs.add(new BasicNameValuePair("accountType","GOOGLE"));
nameValuePairs.add(new BasicNameValuePair("source","ExampleTest"));
nameValuePairs.add(new BasicNameValuePair("service","wise"));
try {
hPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = hClient.execute(hPost);
int status = response.getStatusLine().getStatusCode();
if(status == HttpStatus.SC_OK) {
String temp = EntityUtils.toString(response.getEntity());
authToken=getAuthString(temp);
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void getWorksheetContents() {
HttpClient hClient = new DefaultHttpClient();
HttpResponse response;
HttpGet hGet = new HttpGet(worksheetsheetURL);
hGet.addHeader("Authorization","GoogleLogin auth="+authToken);
try {
response = hClient.execute(hGet);
int status = response.getStatusLine().getStatusCode();
Log.d(TAG,"getWorksheetContents : "+response.getStatusLine());
if(status == HttpStatus.SC_OK) {
String temp = EntityUtils.toString(response.getEntity());
Log.d(TAG, "getWorksheetContents"+temp);
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getAuthString(String content) {
int index=content.indexOf("Auth=");
Log.d(TAG, "index = "+index);
return content.substring(index+5);
}
-Dan
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en