Most of the time Htaccess and Apache can handle proxies like this much easier, but just in case you need to do this, here is the code for a PHP proxy from http://developer.yahoo.com/javascript/samples/proxy/php_proxy_simple.txt
<?php
// PHP Proxy example for Yahoo! Web services.
// Responds to both HTTP GET and POST requests
//
// Author: Jason Levitt
// December 7th, 2005
//
// Allowed hostname (api.local and api.travel are also possible here)
define ('HOSTNAME', 'http://search.yahooapis.com/');
// Get the REST call path from the AJAX application
// Is it a POST or a GET?
$path = ($_POST['yws_path']) ? $_POST['yws_path'] : $_GET['yws_path'];
$url = HOSTNAME.$path;
// Open the Curl session
$session = curl_init($url);
// If it's a POST, put the POST data in the body
if ($_POST['yws_path']) {
$postvars = '';
while ($element = current($_POST)) {
$postvars .= key($_POST).'='.$element.'&';
next($_POST);
}
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
}
// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Make the call
$xml = curl_exec($session);
// The web service returns XML. Set the Content-Type appropriately
header("Content-Type: text/xml");
echo $xml;
curl_close($session);
?>
More Curl Code
This shows how to use curl a little simpler..
>?php
/*
_ _ ____ _
___| | | | _ \| |
/ __| | | | |_) | |
| (__| |_| | _ <| |___
\___|\___/|_| \_\_____|
01/08/2008 By AskApache
http://www.askapache.com/security/curl-google-post-feed.html
This script will login to google reader with the $username and
$password variables and fetch the number of subscribers for
the $feedurl variable that you specify.
DEMO: http://www.askapache.com/online-tools/curl-google-feed/
*/
/****************************************
SETTINGS
****************************************/
// if($_SERVER['REMOTE_ADDR'] !== '1.1.1.1')die();// only allow IP 1.1.1.1
$username=urlencode('youremail@gmail.com');
$password="yourpassword";
$feedurl=urlencode('thefeedurl'); //http://feeds.askapache.com/apache/htaccess
// create cookie file
$google_cookie=tempnam("./","XX");
$url="http://www.google.com/reader/directory/search?q=$feedurl&ck=1199813768546&client=scroll";
$postdata="Email=$username&Passwd=$password&GA3T=5AS_gBsvDHI&nui=15&".
"fpui=3&service=reader&ifr=true&askapache=lovesgoogle&rm=hide&itmpl=true&hl=en&alwf=true&continue=".
$url."&null=Sign in";
$ch = curl_init("https://www.google.com/accounts/ServiceLoginBoxAuth");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $google_cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $google_cookie);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$askapache_curl_google_result = curl_exec ($ch);
curl_close($ch);
$s=array('@]*?>.*?@si','@]*?>.*?@si','@]*?>.*?@siU','@@');
$g=preg_replace($s, '', $askapache_curl_google_result);
$g=preg_match('@href="([^"]*?)"@si',$g,$m);
$ch = curl_init($m[1]);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $google_cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $google_cookie);
$askapache_curl_google_result = curl_exec ($ch);
curl_close($ch);
$g=preg_match('@href="([^"]*?)"@si',$askapache_curl_google_result,$j);
$ch = curl_init("http://www.google.com/reader/directory/search?q=$feedurl");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $google_cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $google_cookie);
$askapache_curl_google_result = curl_exec ($ch);
curl_close($ch);
$y=preg_match('@class="feed-result-stats">([^<]*?)@si',$askapache_curl_google_result,$s);
// output results
header("Content-type: text/plain");
echo "(".$s[1].") Subscribers for feed: ".urldecode($feedurl);
// delete cookie file
unlink($google_cookie);
exit 0;
exit;
/*
"Google AdSense Automatic Login with PHP and CURL"
http://www.askapache.com/webmaster/login-to-google-adsense-using-php.html
"Follow your Adsense earnings with an RSS reader"
http://curl.askapache.com/libcurl/php/examples/rss-adsense.html
"Auto-Login to Google Analytics to impress Clients"
http://www.askapache.com/webmaster/login-google-analytics.html
*/
?>
htaccess and .htaccess rewrite links
Apache Documentation
First, here are several links to the definitive source for Apache 1.3 and Apache 2.0 specifically related to using .htaccess, especially for redirecting URLs and blocking bad bots and spammers.
Apache 1.3
By Ralf S. Engelschall
Apache 2.0
By Ralf S. Engelschall
How to Use .htaccess, mod_rewrite, and Related (for Apache)
Introduction to .htaccess, including what you can do with .htaccess, creating custom error pages, deny/allow access to specific pages or directories, password protection, redirecting URLs, and more. By David Gowans, via freewebmasterhelp.com.
By Andy King, via websiteoptimization.com.
For mod_rewrite beginners, by DaveAtIFG via Webmasterworld, Dec 16, 2002.
By Tamas Turcsanyi, via SitePoint, October 22, 2002.
By Daniel via 4webhelp.net, updated February 09, 2004.
by Bill Humphries via A List Apart, June 30, 2000.
Helpful, easy-to-understand introduction to .htaccess and what you can do with it. Collated by Miraz Jordan via wise-women.org.
SRC: http://brainstormsandraves.com/archives/2005/10/09/htaccess/