第一次在这里问一个问题.通常我可以在不必询问的情况下找到答案,但这次我被困住了,无法弄清楚我错过了什么.
我只是想让我的Android应用在网站上填写表格并提交.我不需要应用程序对发回的任何数据执行任何操作,只需填写表单并提交即可.基本上我正在尝试收集投票应用的结果.我认为表单提交很简单所以我创建了一个Google电子表格并从中制作了一个表单.我想我会将Android应用程序指向表单,然后我会在电子表格中包含所有数据供以后查看.我不能让Android应用程序实际填写表格.这是资源.
private void submitVote(String outcome) {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://spreadsheets.google.com/spreadsheet/formResponse?hl=en_US&formkey=dDlwZzh4bGFvNFBxUmRsR0d2VTVhYnc6MQ&ifq");
List<BasicNameValuePair> results = new ArrayList<BasicNameValuePair>();
results.add(new BasicNameValuePair("entry.0.single", cardOneURL));
results.add(new BasicNameValuePair("entry.1.single", outcome));
results.add(new BasicNameValuePair("entry.2.single", cardTwoURL));
try {
post.setEntity(new UrlEncodedFormEntity(results));
} catch (UnsupportedEncodingException e) {
// Auto-generated catch block
Log.e("YOUR_TAG", "An error has occurred", e);
}
try {
client.execute(post);
} catch (ClientProtocolException e) {
// Auto-generated catch block
Log.e("YOUR_TAG", "An error has occurred", e);
} catch (IOException e) {
// Auto-generated catch block …Run Code Online (Sandbox Code Playgroud)