2014년 11월 30일 일요일

Get multiple values from web api


I need some help. I am just started to use MIT App Inventor 2.  I have created an App after reading this tutorial:

StockQuotes for App Inventor 2

This gives back only one value. My App is working as stockquotes, but gives back a long value like:

{"created_at":"2014-11-17T10:26:27+01:00","entry_id":4157,"field1":"20","field2":"20","field3":"21","field4":"640","field5":"20","field6":"20","field7":"68","field8":"64"}

I would like to show the values as below:

Last Entry: "datetime vale here from the string"
Field1:  " Field1 value here"
Field2: " Field2 here"
and so on...

Can anybody help me how to develop this in App inventor 2?

-- 

You are getting back json data, which is great.

Use the JsonDecode block to convert the response into lists, then use the lookupinpairs block.

See here App Inventor JSON Parsing problem

--
thanks for the help! I have no TinyDB or DB to store the value. How can I solve that without db?

--

you can find TinyDB in the Storage drawer, see also the documentation http://ai2.appinventor.mit.edu/reference/components/storage.html#TinyDB

first do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.htmlto learn the basics of App Inventor, then try something and follow the

--
Lists

List of Lists

TinyDB
ABG's example Build Your Own DB - Part 1  demonstrates filtering


and you might consider:

Tutorials:

AI2 free online eBook   http://appinventor.mit.edu/explore/ai2/tutorials.html   ... the links are at the bottom of the Web page.

You question seems to indicate you should read the free online eBook to learn HOW to program with AI2 blocks.  You can do temporarily save on a List, lists are not persistant, they disappear when an app closes.  Data in a TinyDB is persistent and AI2 has the blocks to do that.

And if you did the tutorials, you would know how to use a Fusion table to 'solve' your issue Pierre.

--
Thanks! meanwhile I have managed to do this, but got error message: when it shoudl show the result:

Error200.

So it seems to be working with response 200, but not showing any value. project is attached.
Can you have a look at it? Thanks! you can try with for example 14370 value


--
response cocd 200 means actually success...

If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...


To download the aia file, upload it to  App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...

--
Oh ok, sorry for posting than the whole project file! So blocks attached.
It seems success yes, because of repsonse code 200, but I would like to have all the 8 fields on screen.
I am sure i have made a mistake somewhere...







--
write the responseCode into a global variable to be able to use Do it to debug your blocks

see also tip 4 here


--
Before your answer, I have modified the call.ready block and the else statement like on the screen.
Now it is working, but beside gives back the warning what you can find also on the attached screen.




--
you can't use Do it for local variables...
therefore I recommended to use a global variable instead for your tests


--
Changed to global variable. Now it is 200 response, so this is fine! Also after exporting and importing back again, there are no warnings! 

Thanks for all the help, and also for the tutorials! Are there any tutorial regarding the GUI? Not to be as flat as it is now :)




--
Also can you please help me how can I format the text in a simple text section? For example "Last datetime" should be bold.
now it is showing the results:

Lastdate: value
T0: value
T1: value
...

I would like to format with bold text and also bigger fonts, and put in a kind of table to have well organised...



--

댓글 없음:

댓글 쓰기