Hello, I need to use cURL to post some data and send cookies (in the same request).
I have no idea how to do this so please help!
Thanks,
tenx23
Hello, I need to use cURL to post some data and send cookies (in the same request).
I have no idea how to do this so please help!
Thanks,
tenx23
Topic 1: Posting data
PHP Code:
<?php
$ch = curl_init("http://example.com/curl_target.php");
curl_setopt($ch, CURLOPT_HEADER, 0); // don't want header info
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // make the result the return value of curl_exec
curl_setopt($ch, CURLOPT_POST, 1); // do a POST, not a GET
curl_setopt( $ch, CURLOPT_POSTFIELDS , 'para1=val1¶2=val2' ); // add the POST info
$output = curl_exec($ch); // send it
curl_close($ch); // clean up
echo $output; // show the response
Nothing is always absolutely so.
Start with the documentation for curl_setopt, which lists the options you should set. You can use curl_setopt_array rather than curl_setopt to set multiple options simultaneously, but the documentation for the latter is what you need to read.
Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.Misson, not Mission.