Skip to content

Instantly share code, notes, and snippets.

@therealklanni
Created November 22, 2011 04:53
Show Gist options
  • Save therealklanni/1384925 to your computer and use it in GitHub Desktop.
Save therealklanni/1384925 to your computer and use it in GitHub Desktop.
Stupidly simple PHP proxy
<?php
// Stupidly simple PHP proxy for AJAX (HTTP GET) requests. Written by Kevin Lanni.
$dest = ''; // Set to the remote script URL (i.e. http://remotehost.com/some.php)
$a = array();
foreach ($_GET as $k=>$v) {
$a[] = "{$k}={$v}";
}
echo file_get_contents($dest.'?'.implode('&',$a));
?>
@adius
Copy link

adius commented Apr 6, 2012

....or even simpler:

<?php
$dest = '';
echo file_get_contents($dest.'?'.http_build_query($_GET));
?>

;-)

@adius
Copy link

adius commented Apr 6, 2012

...

<?php
$dest = '';
echo file_get_contents($dest.'?'.$_SERVER['QUERY_STRING']);
?>

@therealklanni
Copy link
Author

Thanks, those are some pretty good ideas. Feel free to fork this gist :)

I'll try your methods out when I have a little time to play around and then update my gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment