From 7c7bdd31c0c0db4998a7eab12029d713922c4bb8 Mon Sep 17 00:00:00 2001 From: peter279k Date: Wed, 27 Oct 2021 18:29:08 +0800 Subject: [PATCH] Closes issue #55 --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 5277109..536957f 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,28 @@ printf('Dimensions: %s', print_r($dimensions, true)); $browser->close(); ``` +**Example** - send post request: + +```php +$puppeteer = new Puppeteer(); +$browser = $puppeteer->launch(); +$page = $browser->newPage(); + +$page->setRequestInterception(true); +$page->on('request', new JsFunction( + ['interceptedRequest'], + " + var data = { + 'method': 'POST', + 'postData': '" . http_build_query($options['form_params']) . "' + }; + interceptedRequest.continue(data); + " +)); + +$response = $page->goto('https://example.com'); +``` + ## Requirements and installation This package requires PHP >= 7.3 and Node >= 8.