Discussion Forums  >  Config Data, JSON, App Refresh

Replies: 11    Views: 161

SkullyFox
Apple Fan
Profile
Posts: 169
Reg: Jul 15, 2012
Armidale
12,190
08/27/12 11:54 PM (13 years ago)

Where is JSON Data

This may be a real "duh" question - but it has been bugging me. When looking at the screen data URL - it points to http://mydomain.com/bt_server/api/app/?command=getChildItems - blah blah and so on, but all that is in that directory obviously is the php script, no config file. Is the JSON data just one single file, as shown in the "Configuration Data" screen in CP - and if so, where is it? Dave
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
08/28/12 12:38 AM (13 years ago)
Hi Dave, It is a single file, and that gets presented to you in the form of the BT_Config.txt file. You can also view it in the "Configuration Data" screen as you noted. The data itself gets generated through an API call to the buzztouch servers, if I understand correctly how things work. So, there is no single file you could find on your BT Server that has the same info, as it's dynamically generated each time a call is made to the API, and the contents depend on what screens you have defined. At least that's how I understand it to work! Mark
 
SkullyFox
Apple Fan
Profile
Posts: 169
Reg: Jul 15, 2012
Armidale
12,190
like
08/28/12 02:26 AM (13 years ago)
In a way i also got that impression, but i thought that since it was displayed in a "text file" sense in the configuration data screen, that it would hopefully be a single file somewhere in BT_Server, maybe thats just me hoping as it would have made life SO much easier. Thanks for the input Mark! Dave
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
08/28/12 12:26 PM (13 years ago)
I've been trying to understand this also. So excuse the pointed questions. ***The data itself gets generated through an API call to the buzztouch servers, if I understand correctly how things work. *** Why do you believe this? Do you have a reference ? As I indicate below this I believe is erroneous. ****So, there is no single file you could find on your BT Server that has the same info*** Some data is on your BT server. See the database, but this only contains the "core" data. Haven't found the "screen" data. Don't believe it's on Buzztouch.com (would be silly to place it there). Plus without an API key i believe the app will continue to work, if so, couldn't involve an API call. **** as it's dynamically generated each time a call is made to the API, **** Don't believe this is correct. You can view the Config file in the Control Panel and don't believe this triggers an API call. Agree the file is created dynamically but not via an API call. The refresh app data process "views" is separate from API calls. The view is the call to the Config file. Fred
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/28/12 01:44 PM (13 years ago)
Lets see if this makes sense to everyone. In a way, ALL of you are correct, just in different ways. Is it a file? Yes, when you package an app for download it becomes a file in the project. You can see this file in the download. Is it an API call, yup. The API call made to create the config.txt data is NOT calling buzztouch.com, it's calling "mysite.com" (unless the app is still on buzztouch.com). Is it dynamically generated, yup. So, now that all of you are confused, I'll explain the details. And, I'll assume it's a self hosted panel because of the reference to: http://mydomain.com/bt_server/api/app/?command=getChildItems (mydomain suggests this is a self hosted panel) --When you "view" the configuration data screen in the control panel, you are not viewing the contents of a text file. You are viewing dynamic data created by way of a database query. --Screen data: All the configuration data for every app in your control panel is stored in your database, not ours. bt_applications holds records for each app in the panel. bt_items holds records for all sorts of other stuff. "bt_items" could be screens, menu items, buttons, map locations, etc. The bt_items table is used by plugin developers to save all sorts of miscellaneous information about a screen. In most cases, the bt_items table holds rows for each screen (like a map screen, a menu screen, a splash screen, etc.). And, it holds "childItems" for things like map locations, images, buttons, menu rows, quiz questions, etc. So, one table holds lots of different types of information - this is the bt_items table. --Single file somewhere. You could easily copy the config data you see in the control panel, paste it in a text file, save the file. Then, you could "point" to this config file using the dataURl for the app instead of using the "api" on your server to produce the config data when the user taps refresh. Why would you want to do this? I can think of lots of reasons. There are pros and cons to each solution. The most obvious reason you would want to do this is that you could move the config.txt file off your server an onto another server and still keep the "refresh" logic working. In this case you would need to update this saved file whenever you made changes in your control panel because it's "disconnected." When you use the standard dataURL for an app in your control panel, you're saying "hey app, when somebody taps refresh, contact my server, make an API call to the SAME server that hosts the control panel, then spit-out the config data." This process does not save a text file anywhere, it produces the data in real time from an API call (database query). Have a look at the directory structure of the self hosted panel, it has an /api directory. This means that you CAN make API CALLS to your own self hosted server. Your self hosted server only understands a FEW API call methods, such as "getAppData" or "getChildItems", etc. When making API calls to your own server, the URL or FORM post variables must contain the API key and secret listed in your control panel for each app. Each app has it's own API key and secret. This is different than the API key you use to connect your control panel to the buzztouch.com API (a totally different API with totally different methods and purposes not available for you to see, change, hack up). The reason each app in your panel has an api key and secret is that it allows you to invalidate existing keys or create new keys. Imagine giving another developer "access" to your apps data. One way to do this would be to give him the URL to your api, give him his own API key / secret, and tell him to make an HTTP request for the data. If you changed your mind later and no longer wanted to allow him "access" to this data you could invalidate his key. Get it?
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
08/28/12 01:45 PM (13 years ago)
Got it! Thanks! Good to know I didn't completely slaughter the explanation!
 
SkullyFox
Apple Fan
Profile
Posts: 169
Reg: Jul 15, 2012
Armidale
12,190
like
08/28/12 02:00 PM (13 years ago)
Got it, thanks for clearing that up, it will help a lot. I've got a single page "app" I created outside BT that I want to manipulate into a plugin and it is proving quite challenging to wrap my head around the conversion, so I was starting here.. Appreciate the responses guys! Dave
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
08/28/12 02:18 PM (13 years ago)
@David, thanks for the excellent response. Took me a couple of reads to comprehend. If you feel inclined to please expand on "One way to do this would be to give him the URL to your api, give him his own API key / secret, and tell him to make an HTTP request for the data. If you changed your mind later and no longer wanted to allow him "access" to this data you could invalidate his key." I understand the concept but not the how-to. Fred
 
SkullyFox
Apple Fan
Profile
Posts: 169
Reg: Jul 15, 2012
Armidale
12,190
like
08/28/12 06:35 PM (13 years ago)
SO the way i understand this is; - when the app is connected tothe CP, it sends a request with the App ID and secret, which is then returned with data from the database (compiled as the text in Configuration Data when viewed) - This is independant of the BT API system - meaning you can run the apps on your CP without having a BT API? - If you so desired, you could "copy" the text from the configuration data into a text file and store on another server, you would then "point" your apps to that file? or is there more to it then simply pointing it to a path like (for example); "http://www.mydomain/apps/api/appname/appname.txt" to which you could then edit as you required to do what you want it to do - although this is not possible via the CP as it is not "connected" (but you could make changes to the control panel properties anyway, have it create the JSON data and display it in Configuration data for the app despite not being connected to one, then simply copy/paste into your own previously mentioned configuration text file your pointing your app at? (for simple modifications aside from the custom properties you are implementing)) i hope these questions arent too hopeless.. Dave
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
08/28/12 08:45 PM (13 years ago)
- when the app is connected tothe CP, it sends a request with the App ID and secret, which is then returned with data from the database (compiled as the text in Configuration Data when viewed) Yes, and this data is stored in localStorage. The app will use this cached file instead of the BT_config.txt file that you packaged into the binary. - This is independant of the BT API system - meaning you can run the apps on your CP without having a BT API? Yes, what you can't do is download the source code. - If you so desired, you could "copy" the text from the configuration data into a text file and store on another server, you would then "point" your apps to that file? or is there more to it then simply pointing it to a path like (for example); Yes, on my site there's an article that describes how-to and why you should. Go to www.MySkylla.com > Documentation > Config file Don't use the file name you gave but the file name of the file where it's posted. to which you could then edit as you required to do what you want it to do - although this is not possible via the CP as it is not "connected" Simply make modifications in control panel and post to this file. (but you could make changes to the control panel properties anyway, have it create the JSON data and display it in Configuration data for the app despite not being connected to one, then simply copy/paste into your own previously mentioned configuration text file your pointing your app at? (for simple modifications aside from the custom properties you are implementing)) Correct. Fred
 
SkullyFox
Apple Fan
Profile
Posts: 169
Reg: Jul 15, 2012
Armidale
12,190
like
08/28/12 09:10 PM (13 years ago)
Excellent stuff, think i have the general idea - i want to play with this alot more, i think there is alot of room there for management of content updates outside simple changes, gonna go have a play :D Dave
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
08/29/12 10:09 AM (13 years ago)
Thanks for referring me to this thread @fred, very informative - wow! API calls explained. Cheers, David buzztouchmods.com
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.