Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

FYI - Send post request #55

Open
hotrush opened this issue Jul 26, 2019 · 1 comment · May be fixed by #155
Open

FYI - Send post request #55

hotrush opened this issue Jul 26, 2019 · 1 comment · May be fixed by #155
Labels
documentation This issue probably exists due to a lack of documentation

Comments

@hotrush
Copy link

hotrush commented Jul 26, 2019

$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($uri);

You can add into docs or smth

@nesk nesk added the documentation This issue probably exists due to a lack of documentation label Sep 21, 2020
peter279k added a commit to peter279k/puphpeteer that referenced this issue Oct 27, 2021
@peter279k peter279k linked a pull request Oct 27, 2021 that will close this issue
@longbinzhao
Copy link

longbinzhao commented May 24, 2022

$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($uri);

You can add into docs or smth

when i used this way, the website didn't get the post data

try this:
$page->on('request', new JsFunction(
['interceptedRequest'],
"
var data = {
'method': 'POST',
'postData': '".http_build_query($options['form_params'])."',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded'
},
};
interceptedRequest.continue(data);
"
));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation This issue probably exists due to a lack of documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants