Skip to content

Commit

Permalink
Merge pull request #8 from skorasaurus/curl
Browse files Browse the repository at this point in the history
replace file_get_contents with curl function
  • Loading branch information
enam committed Sep 9, 2015
2 parents 34d2806 + 94c4c4d commit f053122
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion php/cartodbProxy.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
<?php
session_cache_limiter('nocache');
$cache_limiter = session_cache_limiter();

function url_get_contents ($inputURL) {
if (!function_exists('curl_init')){
exit('Sorry, CURL is not installed on your server.');
}
$ch = curl_init();

$options = array(CURLOPT_URL => $inputURL,
CURLOPT_RETURNTRANSFER => true
);

curl_setopt_array($ch, $options);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}

function goProxy($dataURL)
{
$baseURL = 'http://CARTODB-USER-NAME.cartodb.com/api/v2/sql?';
// ^ CHANGE THE 'CARTODB-USER-NAME' to your cartoDB url!
$api = '&api_key=';
// ^ENTER YOUR API KEY HERE!
$url = $baseURL.'q='.urlencode($dataURL).$api;
$result = file_get_contents ($url);
$result = url_get_contents ($url);
return $result;
}
?>

0 comments on commit f053122

Please sign in to comment.