Skip to content

Use PHP CURL simulate HTTP requests for online tool toolfk online Programmer toolbox

hubs edited this page Dec 26, 2018 · 1 revision

      This paper to recommend [ToolFk] is a programmers often use a free online test kit, ToolFk feature is focused on everyday programmer development tools, without having to install any software, as long as the content execution affixed by a button, able to obtain the contents of the desired results.ToolFk also supports   BarCode Barcode generated online ,  QueryList collector ,  PHP code is run online ,  PHP confusion, encryption, decryption ,  Python code is run online JavaScript online operation ,YAML formatting tools , HTTP simulation query tool HTML online toolbox JavaScript online Toolbox ,CSS online toolbox JSON online toolbox unixtime timestamp conversion Base64 / the URL of / native2ascii conversion CSV conversion kit XML online toolbox the WebSocket online tools Markdown online toolbox Htaccess2nginx conversionHex conversion online online encryption toolkit ,online pseudo-original tools online APK decompile online web screenshot tool online random password generation online generate two-dimensional code qrcode online Crontab Expression Builder ,the online short URL Generator Online calculator tool . And more than 20 daily programmer development tools, can be considered a very comprehensive website programmer's toolbox.

Site name: ToolFk
website links: https://www.toolfk.com/
Tools link: https://www.toolfk.com/tool-online-http

? Teaching Code

This tool [Online PHP CURL? Simulation test tools] relies on PHP CURL library,? PHP native language, easy to use, use the following code

STEP 1

STEP 2

DOCKER CORE USING THE FOLLOWING CODE, THE MAIN FILE IS A WRITE, EXECUTE THE FILE, AND THEN CLOSE THE DOCKER.

static function http ($ url, $ params = '', $ method = 'GET', $ cookie = '') {

        $ Header = array (
            "Cache-control: no-cache",
            "Postman-token: 9f6b3c33-c23d-e754-7cd7-d3da69da4ad4"
        );
        if ($ cookie) {
            $ Cookie_arr = explode ( "&", $ cookie): [];?
            $ Header = array_merge ($ cookie_arr, $ header);
        }
        $ Opts = array (
            CURLOPT_RETURNTRANSFER => 1,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false,
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 15,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_FOLLOWLOCATION => 1,
            CURLOPT_HEADER => 0,
            CURLOPT_AUTOREFERER => true,
            CURLOPT_USERAGENT => self :: USER_AGENT_DEFAULT,
            CURLOPT_HTTPHEADER => $ header,
        );

        switch (strtoupper ($ method)) {
            case 'GET':
                $ Opts [CURLOPT_URL] = $ url (is_array ($ params) http_build_query ($ params): $ params?);. '?'.
                break;
            case 'POST':
                // determine whether the file transfer
                $ Params = (? Is_array ($ params) http_build_query ($ params): $ params);
                $ Opts [CURLOPT_URL] = $ url;
                $ Opts [CURLOPT_POST] = 1;
                $ Opts [CURLOPT_POSTFIELDS] = $ params;
                break;
        }
        / * Initialize and curl request * /
        $ Ch = curl_init ();
        curl_setopt_array ($ ch, $ opts);
        $ Data = curl_exec ($ ch);
        $ Error = curl_error ($ ch);
        curl_close ($ ch);
        if ($ error) {
            return $ error;
        } Else {
            return $ data;
        }
    }

It is worth a try for three reasons:

  1. Integrate various programmers often used in development and testing tools.

  2. Simple and beautiful atmosphere of the site pages

  3. Online support formatting code execution, APK online decompile, online high-strength password generator, two dozen screenshots online web tools service

  4. Also recommend its sister network  www.videofk.com  video download Toolbox 

This link: http://www.hihubs.com/article/364

Clone this wiki locally