Contrasting GET and POST
Obviously the cURL extension has other functions, but by and large most HTTP requests made using the cURL extension will follow the sequence of operations shown in the above example. Let’s compare this with a POST request. <?php $data = array( 'parami' => 'valuel', 'param2' => 'value2', 'filel' => '@/path/to/file', 'file2' => '@/path/to/other/file' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost.example/process'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); ?> Here are the differences between this example and the previous one.
Here are a few other cURL configuration setting constants related to the request method.
© cURL Extension — Web Scraping >>> Back to TABLE OF CONTENTS <<< | |
Views: 424 | |
Total comments: 0 | |