We are getting the request from Android app as json array. For example:
$var = [{"username":"kp","mailid":"kp#gmail.com","phoneno":"9876543563","groupname":"android"}]';
I want to make this static data (kp, kp#gmail.com, 9876543563, android) as dynamic to insert the values into database.
In what method we are getting the data? And from an android app, is it POST or GET variable, or an other method? Please let me know how to make this value dynamic which is coming from the android app.
How to do you want to send the data from Android App? Is it needed to be namely JSON-format?
I think the most useful case is to use usual, e.g., POST data and retrieve this using base methods to save it inside PHP. You can use, of course, GET format for 'short' request.
For instance,
Android sends using GET: http://yourcompany.com/senddata?username=name&mailid=e#yourmail.com
You PHP code (very-very-very simple approach):
/// ... initialization...
$sql = "INSERT INTO users (username, email) VALUES ('". ($_POST["username"]) . "', '". ($_POST["mailid"]) . "')";
mysqli_query($conn, $sql)
PHP insert example
To create POST or GET request in Android I would recommend to use JSOUP library
Download
A simple example for jsoup:
Document doc = Jsoup.connect("http://yourcompany.com/url?var1=a").get();
I'm trying to filter a JSON url results using App Inventor 2, following sample codes from here1 and here2, but I still cannot get it done right. I only get one result at a time.
The JSON results are data in the form shown in the following figure:
{
"field1":"alphaNumeric1",
"field2":"aNumber1",
"field3":"DD/MM/YY",
"field4":"HH/MM/SS",
"field5":"https://",
"field6":"aText",
"field7":"aNumber2",
"field8":"alphaNumeric2",
"field9":"aNumber3",
"field10":"alphaNumeric3"
}
The JSON url is constantly updated, so are the results, but this is not a problem for now. I can get it read by a timer.
The problem is that from the above results, I need to parse "field2", "field5", "field6", in according labels in the app.
So e.g., when I input a "aNumber1" to get searched in the JSON data, and have the result in a label.
Is it possible this JSON data search be done with App Inventor 2?
Anyone kind enough please answer with a sample blocks if possible.
Thank you all in advance!
[EDIT 1]
No matter what I've tried, JSON could not get filtered right. Therefore I'm to filter the url results in XML.
The XML results are data in the form shown in the following figure:
<results>
<decision>
<alphaNumeric1>ABC1D</alphaNumeric1>
<aNumber1>ABCD</aNumber1>
<aDate>123</aDate>
<doc>HTTP</doc>
<aNumber2>1234</aNumber2>
<alphaNumeric2>TYPE</talphaNumeric2>
<aNumber3>12345</aNumber3>
<aNumber4>1234567</aNumber4>
<aText>SomeText</aText>
<aHour>00:00:00</aHour>
</decision>
.
.
.
<decision>
.
.
.
</decision>
.
.
.
</results>
I have tried to follow the example at here2, but I don't get it right. According to the XML output, what should I put in starTag and endTag, to get a parsing result if I'm searching for e.g. aNumber4 value (= 1234567) ?
Can someone respond with an answer?
[EDIT 2]
Well I'm trying to make some progress here following the example at here3.
The XML is being parsed with a runtime error "this is not a well formatted list of pairs".
Following is the blocks code I'm using:
Why is that so, since I'm following the example to the letter? Any clues anyone to solve this out?
well, your blocks look a little bit strange...
you have a complex list of lists, just use Do it to find out, how it looks like after each step of using lookup in pairs...
It helps to follow the already provided links:
how to work with lists
how to work with list of lists (pdf) by appinventor.org
see also An example of a complex List of Lists
In the example blocks below I looked for the first <decision> and displayed the value of tag aDate in Label1 like this
you might want to loop through the different <decision>s using a for each in list loop....
I am new to Parse and i am working on a Project that uses Android PARSE Sdk so i was wondering on how can i make a where query with or condition using the android sdk.
I want to make a query like this [Psuedo code]
Select * from employ where employId is ("1","2","3")
I found this on parse documentation, i don't know if it helps or not.
Edit:
This is what i found on PARSE but its not working
String[] id= {"1","2","3"};
query.whereContainedIn("employId ", Arrays.asList(id));
It returns me an empty list but if i query them one by one i get result... Can anyone tell me whats wrong ?
You can use whereContainedIn to select specific rows. See this post you can get more ideas. https://www.parse.com/questions/different-arrays-and-wherecontainedin-for-android.
List<String> employId = new ArrayList<String>();
employId.add("1"); employId.add("2"); employId.add("2");
query.whereContainedIn("employId", employId);
If you are still not clear. check this https://www.parse.com/docs/android_guide#queries
I have found the solution and i must say its pretty lame of PARSE to not mention this anywhere in there documentation.
The problem was that the values that i was using inwhereContainedIn method were of type String but in reality they were pointers to another table's row.
I was trying to get the values using only there ids[as it is displayed on parse] but instead i had to pass the whole object in order to retrieve them. That was the reason on why it was returning empty list.
The thing is Even though it displays IDs [pointer to object in a table] we cant search using only ID's instead we have to use complete Parse objects if we want to search a table based on Specific Object.
how to extract some criteria from this page http://www.zigwheels.com/api/zigtvApi.php?method=data&module=News§ion=News
and filter this ( content_id , thumbnail, summary , headline , image) to display them as rss feeds in my android GUI
The output from that URL looks like a JSON feed. You can easily parse JSON data in Android using the JsonObject - see this tutorial for a comprehensive example.
A better (and probably easier) solution would be to use Google Gson and extract the object that way. I've written a full (compilable) program you can use as an example here.
You are receiving a JSONArray from that page. You should create some objects from that JSONArray which will be later displayed in a ListView. For retrieving objects from that feed you could use Json or Gson as #Marvin Pinto suggested, or you could also have a look at my ObjectFactory project, which is a very simple and easy to use parser. It can simply create your objects from a json or xml feed, and you could also use it asynchronously.
After you fetch your objects, with your desired option, you can create a ListAdapter and use it to display your objects in your ListView.
Hi, I am new to android. I want to get data from webservice. in which key's are store in an array . and ley values stores in another array. In webservice data are display like,
{"1":{"para_id":"1","para_parent_id":"0","para_level":"0","para_type":"0","para_value":"Salution","para_desc":"Salution","para_sort_order":"1","para_tech_desc":"Salution","created_dt":"2011-08-11 19:47:05","created_by":"1","updated_dt":"2011-08-11 19:47:05","updated_by":"1","status":"A"},"1001":{"para_id":"1001","para_parent_id":"1","para_level":"0","para_type":"1","para_value":"Mr.","para_desc":"Mr.","para_sort_order":"1","para_tech_desc":"Mr.","created_dt":"2011-08-11 19:47:21","created_by":"1","updated_dt":"2011-08-11 19:47:21","updated_by":"1","status":"A"},"1002":{"para_id":"1002","para_parent_id":"1","para_level":"0","para_type":"1","para_value":"Ms.","para_desc":"Ms.","para_sort_order":"1","para_tech_desc":"Ms.","created_dt":"2011-08-11 19:49:00","created_by":"1","updated_dt":"2011-08-11 19:49:00","updated_by":"1","status":"A"},"1003":{"para_id":"1003","para_parent_id":"1","para_level":"0","para_type":"1","para_value":"Mrs.","para_desc":"Mrs.","para_sort_order":"1","para_tech_desc":"Mrs.","created_dt":"2011-08-12 09:40:14","created_by":"1","updated_dt":"2011-08-12 09:40:14","updated_by":"1","status":"A"},"2":{"para_id":"2","para_parent_id":"0","para_level":"0","para_type":"0","para_value":"Appointment Types","para_desc":"Appointment Types","para_sort_order":"1","para_tech_desc":"Appointment Types","created_dt":"2011-08-16 15:43:15","created_by":"1","updated_dt":"2011-08-16 15:43:15","updated_by":"1","status":"A"},"2001":{"para_id":"2001","para_parent_id":"2","para_level":"0","para_type":"2","para_value":"Scheduled","para_desc":"Scheduled","para_sort_order":"1","para_tech_desc":"Scheduled","created_dt":"2011-08-16 15:43:36","created_by":"1","updated_dt":"2011-08-16 15:43:36","updated_by":"1","status":"A"},"2002":{"para_id":"2002","para_parent_id":"2","para_level":"0","para_type":"2","para_value":"Cancelled","para_desc":"Cancelled","para_sort_order":"1","para_tech_desc":"Cancelled","created_dt":"2011-08-16 15:43:51","created_by":"1","updated_dt":"2011-08-16 15:43:51","updated_by":"1","status":"A"},"2003":{"para_id":"2003","para_parent_id":"2","para_level":"0","para_type":"2","para_value":"Re-Scheduled","para_desc":"Re-Scheduled","para_sort_order":"1","para_tech_desc":"Re-Scheduled","created_dt":"2011-08-16 15:44:24","created_by":"1","updated_dt":"2011-08-16 15:44:24","updated_by":"1","status":"A"},"2004":{"para_id":"2004","para_parent_id":"2","para_level":"0","para_type":"2","para_value":"Deleted","para_desc":"Deleted","para_sort_order":"1","para_tech_desc":"Deleted","created_dt":"2011-08-16 15:44:38","created_by":"1","updated_dt":"2011-08-16 15:44:38","updated_by":"1","status":"A"},"3":{"para_id":"3","para_parent_id":"0","para_level":"0","para_type":"0","para_value":"Customer Status","para_desc":"Customer Status","para_sort_order":"1","para_tech_desc":"Customer Status","created_dt":"2011-08-29 12:51:48","created_by":"1","updated_dt":"2011-08-29 12:51:48","updated_by":"1","status":"A"},"3001":
I want to sore key "1" ,"2", "3" in an array and related value in another array.and get the data. How can i do this?
Well, this looks like JSON, so use a JSON-Parser, for a tutorial see here. You can make your JSON more readable (especially when asking on SO) using the JSON beautifier