Skip to content

Instantly share code, notes, and snippets.

@bmcbride
Created September 18, 2013 19:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save bmcbride/6614373 to your computer and use it in GitHub Desktop.
Save bmcbride/6614373 to your computer and use it in GitHub Desktop.
Simple PHP proxy
<?php
$ch = curl_init($_GET['url']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
@bmcbride
Copy link
Author

Usage example:

$.getJSON("proxy.php?url=http://www.someserver.com/data.geojson", function (data) {
    myGeoJSONlayer.addData(data);
}).complete(function () {
    map.fitBounds(myGeoJSONlayer.getBounds());
});

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