Location: PHPKode > scripts > HTTP Request class > http-request-class/proxycurl.php
<? 
/*
Author : Martin Fasani [ www.movil.be ]
lastMod: 20050701 [YYYYMMDD]
Simple CURL proxy.
The headers info and request are sent by the other page, so this acts just as a proxy.
*/

$send     = $GLOBALS['HTTP_RAW_POST_DATA']; 
$header[] = "MessageType:$_SERVER[HTTP_MESSAGETYPE]"; 
$header[] = "Content-Type:$_SERVER[CONTENT_TYPE]";   
$ch      = curl_init();


/*
API KEY NEEDS TO BE INSERTED HERE
NOTICE that in order to avoid pasting the googleAPI key in public we will replace it here:
                                                 |
*/

$send    = ereg_replace("@apikey","googleAPIkey",$send);

curl_setopt($ch, CURLOPT_URL,      $_GET['url'] );
curl_setopt($ch, CURLOPT_POST,     1);
curl_setopt($ch, CURLOPT_POSTFIELDS,    $send);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
if (!ch) { die ("Cannot initialize a new cURL handle\n"); }
$data = curl_exec($ch);
if (is_int($data)) {
    die ("cURL error:".curl_error($ch)."\n"); 
}
echo $data;
curl_close($ch);
?>
Return current item: HTTP Request class