26 November 2018

Instead of curl I like to use http request function from a long and stable framework
PHP: http request function, alternative to curl or file_get_contents
. Because I find curl to be tedious. Using this function it's easy to do all requests.

Source code viewer
  1. require_once 'request.php';
  2.  
  3. $response = request('https://browse-tutorials.com', array(
  4. 'method' => 'POST',
  5. 'headers' => array(
  6. 'Content-Type' => 'application/json',
  7. 'Accept' => 'application/json',
  8. ),
  9. 'data' => json_encode(array(
  10. // ... json array
  11. )),
  12. ));
  13.  
  14. print_r($response);
Programming Language: PHP