How do I send a POST request with PHP?

前端 未结 13 1560
暗喜
暗喜 2020-11-21 05:40

Actually I want to read the contents that come after the search query, when it is done. The problem is that the URL only accepts POST methods, and it does not t

13条回答
  •  日久生厌
    2020-11-21 05:47

    The better way of sending GET or POST requests with PHP is as below:

    setOptions(array('cookies' => array('lang' => 'de')));
        $r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
    
        try {
            echo $r->send()->getBody();
        } catch (HttpException $ex) {
            echo $ex;
        }
    ?>
    

    The code is taken from official documentation here http://docs.php.net/manual/da/httprequest.send.php

提交回复
热议问题