Invio variabili dalla pagina http://localhost/test2/index1.php alla pagina http://localhost/test2/index2.php con curl.
File: http://localhost/test2/index1.php
File: File: http://localhost/test2/index2.phpCodice PHP:
$Curl_Session = curl_init('http://localhost/test2/index2.php');
curl_setopt ($Curl_Session, CURLOPT_POST, 1);
curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "option=com_content&task=blogcategory&id=24&Itemid=55");
curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
curl_exec ($Curl_Session);
curl_close ($Curl_Session);
La chiamata POST viene effettuata correttamente da http://localhost/test2/index1.php alla pagina http://localhost/test2/index2.phpCodice PHP:
foreach($_POST as $key=>$value)
print $key . " = " . $value . "
";
127.0.0.1 - - [04/Mar/2009:20:38:10 +0100] "POST /test2/index2.php HTTP/1.1" 200 399
192.168.1.2 - - [04/Mar/2009:20:38:10 +0100] "GET /test2/index1.php HTTP/1.1" 302 399
Come gli dico a curl nello script index1.php che dopo la chiamata desidero visualizzare la pagina index2.php con le variabili $_POST invece dello script index1.php?
Grazie per un suggerimento