PHP Classes

File: proxycurl.php

Recommend this page to a friend!
  Classes of Martin Fasani  >  HTTP Request class  >  proxycurl.php  >  Download  
File: proxycurl.php
Role: Auxiliary script
Content type: text/plain
Description: Simple CURL proxy
Class: HTTP Request class
Generate Javascript to send HTTP AJAX requests
Author: By
Last change:
Date: 16 years ago
Size: 1,011 bytes
 

Contents

Class file image Download
<?
/*
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);
?>

For more information send a message to info at phpclasses dot org.