• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
TRIGGERcmd
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Pass parameters when using bookmark URLs?

General Discussion
3
12
5.2k
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.
  • R
    Russ @Insaneoctane
    last edited by Russ Nov 8, 2018, 12:18 AM Nov 7, 2018, 11:12 PM

    @insaneoctane, I could add the ability to add a URL parameter to the bookmark URL's. Would that work?

    Like this:

    https://www.triggercmd.com/trigger/bookmark?token=bookmarktoken&params=foo
    

    EDIT: I added that capability. Now you can add &params=foo to the end of your bookmark URL to send a parameter of foo to your command. That assumes you've enabled parameters on your command of course.

    Russell VanderMey

    1 Reply Last reply Reply Quote 0
    • I
      Insaneoctane
      last edited by Nov 9, 2018, 8:07 PM

      @russ said in Pass parameters when using bookmark URLs?:

      https://www.triggercmd.com/trigger/bookmark?token=bookmarktoken&params=foo

      Russ, that is fantastic that you could add that capability so quickly! I tried the API too and I'm getting the same CORS error. I'm SO not that knowledgeable with CORS/networks stuff, but I think the CORS error is because my javascript isn't being allowed to GET the bookmark (or API) without a proper header from triggercmd.com domain???? Have you seen or dealt with this before?

      Here's the errors I'm seeing in the dev console from chrome:

      Access to fetch at 'https://www.triggercmd.com/trigger/bookmark?token=XXXXX&params=75' from origin 'http://127.0.0.1' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains the invalid value ''. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

      XXXX.html:74 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.triggercmd.com/trigger/bookmark?token=XXXXX&params=75 with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

      R 1 Reply Last reply Nov 9, 2018, 11:28 PM Reply Quote 0
      • R
        Russ @Insaneoctane
        last edited by Nov 9, 2018, 11:28 PM

        @insaneoctane, I used this web page to test, and I wasn't able to reproduce the error.

        Can you send me something that would help me reproduce it?

        <!DOCTYPE html>
        <html>
        <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script>
        $(document).ready(function(){
            $("button").click(function(){
                $.get("https://www.triggercmd.com/trigger/bookmark?token=(bookmarkToken)",
                {
                  params: "Donald Duck",
                },
                function(data,status){
                    alert("Data: " + data + "\nStatus: " + status);
                });
            });
        });
        </script>
        </head>
        <body>
        
        <button>Send an HTTP GET request to a page and get the result back</button>
        
        </body>
        </html>

        Russell VanderMey

        1 Reply Last reply Reply Quote 0
        • I
          Insaneoctane
          last edited by Insaneoctane Nov 12, 2018, 11:41 PM Nov 12, 2018, 12:17 AM

          @Russ,
          Just curious if you ran your script from triggercmd.com domain?

          1 Reply Last reply Reply Quote 0
          • R
            Russ
            last edited by Russ Nov 13, 2018, 3:02 AM Nov 13, 2018, 2:52 AM

            @insaneoctane, no I served that page from w3schools. Please try it here:

            https://www.w3schools.com/code/tryit.asp?filename=FX706MSHLN0A

            Russell VanderMey

            I 1 Reply Last reply Nov 13, 2018, 6:18 PM Reply Quote 0
            • I
              Insaneoctane @Russ
              last edited by Nov 13, 2018, 6:18 PM

              @russ
              I can't thank you enough for your time on this issue!
              I ran the snippet from the W3 site you linked to, clicked the button and got nothing. To see what was happening (I'm in Chrome) I hit F12 and opened up the developers console and saw CORS errors. Here's a snip from the console:

              Access to XMLHttpRequest at 'https://www.triggercmd.com/trigger/bookmark?token=(youBookmarktoken)&params=Donald Duck' from origin 'https://tryit.w3schools.com' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains the invalid value ''.
              VM38:1 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.triggercmd.com/trigger/bookmark?token=(youBookmarktoken)&params=Donald Duck with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.
              (anonymous) @ VM38:1
              send @ jquery.min.js:2
              ajax @ jquery.min.js:2
              w.(anonymous function) @ jquery.min.js:2
              (anonymous) @ tryit_view.php?x=0.3774193121824916:8
              dispatch @ jquery.min.js:2
              y.handle @ jquery.min.js:2

              R 1 Reply Last reply Nov 13, 2018, 11:54 PM Reply Quote 0
              • R
                Russ @Insaneoctane
                last edited by Nov 13, 2018, 11:54 PM

                @insaneoctane, I see the same thing in the developers console, but it does actually run Notepad with Donald Duck as the parameter if I give it an actual bookmark token.

                Did you try that?

                Russell VanderMey

                I 1 Reply Last reply Nov 14, 2018, 1:24 AM Reply Quote 0
                • I
                  Insaneoctane @Russ
                  last edited by Nov 14, 2018, 1:24 AM

                  @russ,
                  I did try it after you asked 😉 and yes, it working even though there are CORS errors in the console. Once I saw those, I quit troubleshooting, but it appears it is working. Thanks again for your efforts and a great app!

                  1 Reply Last reply Reply Quote 0
                  • B
                    BugTrapper
                    last edited by Jul 13, 2019, 9:06 AM

                    @russ

                    Can I add more than one parameter and, if yes, how is the syntax ?

                    R 1 Reply Last reply Jul 13, 2019, 1:44 PM Reply Quote 0
                    • R
                      Russ @BugTrapper
                      last edited by Jul 13, 2019, 1:44 PM

                      @bugtrapper, you should be able to pass multiple parameters by putting a space between them, or a %20 between them, like this:

                      https://www.triggercmd.com/trigger/bookmark?token=bookmarktoken&params=foo bar
                      

                      or

                      https://www.triggercmd.com/trigger/bookmark?token=bookmarktoken&params=foo&20bar
                      

                      Russell VanderMey

                      1 Reply Last reply Reply Quote 0
                      • B
                        BugTrapper
                        last edited by Jul 13, 2019, 4:25 PM

                        Thank you 🙂

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