iMacros Http POST to API endpoint

前端 未结 2 1295
后悔当初
后悔当初 2021-01-07 02:32

I want to do an HTTP POST from inside an iMacro to an API endpoint. Effectively, something like the following:

curl -d \"data=foo\" http://examp         


        
2条回答
  •  孤独总比滥情好
    2021-01-07 03:15

    You can use http://wiki.imacros.net/iMacros_for_Firefox with javascript and jquery. Then it's easy with any form, get and post request thing.

    Small javascript example with jquery and imacros for firefox:

    function loadScriptFromURL(url) {
        var request = Components.classes['@mozilla.org/xmlextras/xmlhttprequest;1'].createInstance(Components.interfaces.nsIXMLHttpRequest),
            async = false;
        request.open('GET', url, async);
        request.send();
        if (request.status !== 200) {
            var message = 'an error occurred while loading script at url: ' + url + ', status: ' + request.status;
            iimDisplay(message);
            return false;
        }
        eval(request.response);
        return true;
    }
    
    loadScriptFromURL('https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js');
    $ = window.$,
    JQuery = window.JQuery;

提交回复
热议问题