I have two scripts:
First to send:
$url = "http://localhost/curl2.php";
$data = array('email' => '[email protected]');
$addr = $url . '?' . http_build_query($data);
$ch = curl_init($addr);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_exec($ch);
And second to receive:
if($_SERVER['REQUEST_METHOD'] == "PUT") {
$data = array();
$incoming = file_get_contents("php://input");
parse_str($incoming, $data);
echo "Address: " . filter_var($data["email"], FILTER_VALIDATE_EMAIL);
}
But variable $incoming is empty. How can I do it? Maybe it has something to do with PUT, but I must use PUT.
CURLOPT_POSTFIELDSinstead of appending your fields to the URI (making them GET parameters).