Calling JSON from your HISE instance - to make a simple versioning system....
-
So I've been messing about with the Server calls, making them interact with my wooCommerce server on my web site, and it seems to be working OK.
So late (in bed) last night it occurred to me that all the wooCommerce REST API is doing is sending me a piece of json (pretty complicated json as it turns out). I (and you) dont need a RESTful API to be implemented on our web sites, a simple static file that contains json should work fine...
So I tried it this afternoon, yep works fine, so here's a (conceptual) example.
If your server is called (lets say) https://davescoolpatreonsite.com
All you need do is open up an ftp link and upload a json file to a subdirectory on your web site and you can call it (from HISE or from your browser):
So:
- make a json file something like this:
{ "Name": "MyCoolProduct", "MajorVersion": 1, "MinorVersion" : 0, "MaintenanceVersion" : 0 }
lets call it myCoolProductVersion.json
- make a directory on your server (lets say) called productversions, and upload this json file.
OK check its working from in your favourite browser by using the URL:
https://davescoolpatreonsite.com/productversions/myCoolProductVersion.json
this should return and show you your json file.
If this works, next you need to call it from your HISE product, here's the code:
Server.setBaseURL("https://davescoolpatreonsite.com"); inline function onButton1Control(component, value) { if(value) { Server.callWithGET("productversions/myCoolProductVersion.json", "", function(status, response) { Console.print("heres back from the server:" + trace(response)); }); } }; Content.getComponent("Button1").setControlCallback(onButton1Control);
press the button in the interface - wait a bit (these calls are asynchronous - they don't happen immediately but when they feel like it...) and you should see your HISE object appear...you should be able to work out what to do with it to obtain the data and check it against some internal consts of these numbers.....
Now you only need update your static json file on your web site to tell your product when its up to date or not.
Clearly you can actually send any data you like...presets, descriptions, jokes, free offers, sale notifications etc. etc.
-
Whoa! That seems so obvious, but I didn't realize that. I was probably overcomplicating it with the Woocommerce attributes.
-
@Lindon FYI, After clicking the link: https://davescoolpatreonsite.com/productversions/myCoolProductVersion.json
Google Chrome gives:
DNS_PROBE_FINISHED_NXDOMAIN
warning in my system :) -
At least it doesn't open a porn site like the last dummy URL from another user :)
-
@Christoph-Hart It can be arranged...
-
@Christoph-Hart said in Calling JSON from your HISE instance - to make a simple versioning system....:
At least it doesn't open a porn site like the last dummy URL from another user :)
LOL yeah that was so funny....
-
@orange as it should...
-
@Christoph-Hart said in Calling JSON from your HISE instance - to make a simple versioning system....:
At least it doesn't open a porn site like the last dummy URL from another user :)
That feature can be implemented, in case the user wants to use a warezed version of the plugin :D
-
@Lindon said in Calling JSON from your HISE instance - to make a simple versioning system....:
@orange as it should...
So is this normal because of the json file?
-
@orange said in Calling JSON from your HISE instance - to make a simple versioning system....:
@Lindon said in Calling JSON from your HISE instance - to make a simple versioning system....:
@orange as it should...
So is this normal because of the json file?
It's not a real website ;)
-
@d-healey said in Calling JSON from your HISE instance - to make a simple versioning system....:
@orange said in Calling JSON from your HISE instance - to make a simple versioning system....:
@Lindon said in Calling JSON from your HISE instance - to make a simple versioning system....:
@orange as it should...
So is this normal because of the json file?
It's not a real website ;)
@Lindon said in Calling JSON from your HISE instance - to make a simple versioning system....:
OK check its working from in your favourite browser by using the URL:
https://davescoolpatreonsite.com/productversions/myCoolProductVersion.json
this should return and show you your json file.
I asked because of this :)
-
@orange If Lindon's set up a website called
davescoolpatreonsite
I think I have to take legal action :p -
@d-healey said in Calling JSON from your HISE instance - to make a simple versioning system....:
@orange If Lindon's set up a website called
davescoolpatreonsite
I think I have to take legal action :p:D
-
@Lindon Thanks for your tip!
-
@Lindon said in Calling JSON from your HISE instance - to make a simple versioning system....:
{
"Name": "MyCoolProduct",
"MajorVersion": 1,
"MinorVersion" : 0,
"MaintenanceVersion" : 0
}I am defining a local variable and Console.print like this:
local version_check_identifier = trace(response); Console.print(version_check_identifier);
In console I am seeing that exact text, it is ok.:
{ "Name": "MyCoolProduct", "MajorVersion": 1, "MinorVersion" : 0, "MaintenanceVersion" : 0 }
But how can we pull and check the MajorVersion, MinorVersion, MaintenanceVersion?
-
@Steve-Mohican
Perhaps:
local majV = response.MajorVersion
local minV = response.MinorVersion
etc...
-
@d-healey Oh, now it works! Thank you so much! :)
-
@Steve-Mohican Homework - https://www.w3schools.com/js/js_objects.asp :p
-
@Steve-Mohican
https://docs.hise.audio/scripting/scripting-in-hise/additions-in-hise.html#object-oriented-programming
Sorry, Dave began -