topsecret Posted August 15, 2012 Posted August 15, 2012 Hy guys, I've been searching for this for quite a while now but nada...Before I start, I would like to state that I'm not a developer, I have no knowledge in writing sophisticated code, I'm just scripting at a low level!My girlfriend needed a program whit which she can save her clients names and some info about them + schedule them, change appointment dates etc... I wrote the script, made a nice gui, everything was fine. I used an .ini file to save data - I know, I know, it's not a database, but it was simple and it works just fine. Now she asked me to create an android app that she can put on her phone, that show her the scheduled clients.* the program shows scheduled clients via a ListView item -> after she asked me for the app, I wrote a function that uses the Excel udf to export the table of scheduled client into an excel file (.xls). After exporting the xls, the program uploads it to a directory on her websites server via ftp, this way I created an android app that acts like a widget: she taps it and the app downloads the xls from the website to her phone. It works just fine, she's OK with it, but I'm not...The App Inventor has an inbuilt component that lets you set up a so called TinyWebDB - this is something like a database on the web with a real simple structure (name:value) ... and now the question: How can I interact with this TinyWebDB in autoit?If I could read and write to my TinyWebDB, EVERYTHING would be sooo much more easy!I found this, probably this is the answer, no, not probably, for sure this is the answer, but I don't understand it -----------------------------------------------------------------------------------------------------------------------------------------------TinyWebdb is a script that responds to a HTTP POST call with " URL/getvalue " where URL is the URL you use for the TInyWebDB and /getvalue is a constant that refers to the script in TinyWebDB. You pass along with that a variable called TAG and the value of the tag. What is returned is a single JSON array consisting of 3 values: - the constant "VALUE" array position 0- the tag value that you sent in the call in array position 1- the result in array position 2Below is the code I use in Java to make a call. You can change that to your favorite scripting language. NOTE: POST variables are not included in the URL as GET variables are but rather in Name/value pairs. This may not be the best code since I haven't optimized it. It's part of a comparison of an AI application to the same functionality in the Android Java SDK. The server name has been changed. Hope it helps. String temp1="";HttpPost httppost = new HttpPost("http://tinywebdb.mysrv12311r.com/tinywebdb/getvalue" );HttpClient httpclient = new DefaultHttpClient(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("tag", "mytag")); httpclient.getParams().setParameter("http.useragent", "TinyWebDB/Android dataget");try {httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));HttpResponse response=httpclient.execute(httppost);temp1 = EntityUtils.toString(response.getEntity());//statuscode = response.getStatusLine().getStatusCode();} catch (ClientProtocolException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocklblErrorMessage.setText("HTTP IO Exception");e.printStackTrace();} // Decode the JSON array. Array is zero based so the return value is in element 2try {JSONArray jsonArray = new JSONArray(temp1);lblReturnedValue.setText(jsonArray.getString(2));} catch (JSONException e) {// TODO Auto-generated catch blocklblErrorMessage.setText("Error in JSON decoding");e.printStackTrace();}
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now