HISE Logo Forum
    • Categories
    • Register
    • Login

    Calling JSON from your HISE instance - to make a simple versioning system....

    Scheduled Pinned Locked Moved Documentation
    20 Posts 8 Posters 898 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LindonL
      Lindon
      last edited by Lindon

      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.

      HISE Development for hire.
      www.channelrobot.com

      orangeO 1 Reply Last reply Reply Quote 4
      • Casey KolbC
        Casey Kolb
        last edited by

        Whoa! That seems so obvious, but I didn't realize that. I was probably overcomplicating it with the Woocommerce attributes.

        Casey Kolb
        Founder & CEO of Lunacy Audio
        Composer | Producer | Software Developer

        1 Reply Last reply Reply Quote 1
        • orangeO
          orange @Lindon
          last edited by orange

          @Lindon FYI, After clicking the link: https://davescoolpatreonsite.com/productversions/myCoolProductVersion.json

          Google Chrome gives: DNS_PROBE_FINISHED_NXDOMAIN warning in my system :)

          develop Branch / XCode 13.1
          macOS Monterey / M1 Max

          LindonL 1 Reply Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart
            last edited by

            At least it doesn't open a porn site like the last dummy URL from another user :)

            d.healeyD LindonL orangeO 3 Replies Last reply Reply Quote 2
            • d.healeyD
              d.healey @Christoph Hart
              last edited by

              @Christoph-Hart It can be arranged...

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              1 Reply Last reply Reply Quote 1
              • LindonL
                Lindon @Christoph Hart
                last edited by

                @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....

                HISE Development for hire.
                www.channelrobot.com

                1 Reply Last reply Reply Quote 0
                • LindonL
                  Lindon @orange
                  last edited by

                  @orange as it should...

                  HISE Development for hire.
                  www.channelrobot.com

                  orangeO 1 Reply Last reply Reply Quote 0
                  • orangeO
                    orange @Christoph Hart
                    last edited by

                    @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

                    develop Branch / XCode 13.1
                    macOS Monterey / M1 Max

                    1 Reply Last reply Reply Quote 0
                    • orangeO
                      orange @Lindon
                      last edited by

                      @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?

                      develop Branch / XCode 13.1
                      macOS Monterey / M1 Max

                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @orange
                        last edited by

                        @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 ;)

                        Libre Wave - Freedom respecting instruments and effects
                        My Patreon - HISE tutorials
                        YouTube Channel - Public HISE tutorials

                        orangeO 1 Reply Last reply Reply Quote 0
                        • orangeO
                          orange @d.healey
                          last edited by orange

                          @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 :)

                          develop Branch / XCode 13.1
                          macOS Monterey / M1 Max

                          d.healeyD 1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @orange
                            last edited by

                            @orange If Lindon's set up a website called davescoolpatreonsite I think I have to take legal action :p

                            Libre Wave - Freedom respecting instruments and effects
                            My Patreon - HISE tutorials
                            YouTube Channel - Public HISE tutorials

                            orangeO 1 Reply Last reply Reply Quote 1
                            • orangeO
                              orange @d.healey
                              last edited by orange

                              @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

                              develop Branch / XCode 13.1
                              macOS Monterey / M1 Max

                              ulrikU 1 Reply Last reply Reply Quote 0
                              • ulrikU
                                ulrik @orange
                                last edited by

                                @Lindon Thanks for your tip! 🙏

                                Hise Develop branch
                                MacOs 15.3.1, Xcode 16.2
                                http://musikboden.se

                                1 Reply Last reply Reply Quote 0
                                • ?
                                  A Former User
                                  last edited by

                                  @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?

                                  d.healeyD 1 Reply Last reply Reply Quote 0
                                  • d.healeyD
                                    d.healey @A Former User
                                    last edited by d.healey

                                    @Steve-Mohican

                                    Perhaps:
                                    local majV = response.MajorVersion
                                    local minV = response.MinorVersion
                                    etc...

                                    Libre Wave - Freedom respecting instruments and effects
                                    My Patreon - HISE tutorials
                                    YouTube Channel - Public HISE tutorials

                                    ? 1 Reply Last reply Reply Quote 0
                                    • ?
                                      A Former User @d.healey
                                      last edited by

                                      @d-healey Oh, now it works! Thank you so much! :)

                                      d.healeyD ustkU 2 Replies Last reply Reply Quote 0
                                      • d.healeyD
                                        d.healey @A Former User
                                        last edited by

                                        @Steve-Mohican Homework - https://www.w3schools.com/js/js_objects.asp :p

                                        Libre Wave - Freedom respecting instruments and effects
                                        My Patreon - HISE tutorials
                                        YouTube Channel - Public HISE tutorials

                                        1 Reply Last reply Reply Quote 0
                                        • ustkU
                                          ustk @A Former User
                                          last edited by

                                          @Steve-Mohican
                                          https://docs.hise.audio/scripting/scripting-in-hise/additions-in-hise.html#object-oriented-programming
                                          Sorry, Dave began 🤣

                                          Can't help pressing F5 in the forum...

                                          1 Reply Last reply Reply Quote 0
                                          • ?
                                            A Former User
                                            last edited by

                                            I think I am trying to make advanced things but I need some basic knowledge at the same time 😄 Thanks guys, ok I got the message 😂 @d-healey @ustk

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            10

                                            Online

                                            1.7k

                                            Users

                                            11.8k

                                            Topics

                                            102.6k

                                            Posts