On April 1, 2021, we are moving all of our QuotaGuard Support Documentation to 


https://quotaguard.github.io/qg-docs/


 Please Update Your Support Bookmarks


 Documentation for this article will be maintained at 


https://quotaguard.github.io/qg-docs/quickstart-ruby 


Please click on the above link to ensure you are reading 

the most recent and updated documentation.


Installation

When you sign up with QuotaGuard, you will be provided with a unique username and password that you can use when configuring your proxy service in your application: 

http://username:[email protected]:9292


We recommend you store the connection string in an environment variable QUOTAGUARD_URL to maintain compatibility with platforms like Heroku and CloudControl.


You can test your proxy setup using curl: 

$ curl -x username:[email protected]:9292 http://www.google.com/

 

Integration

PHP cURL is the easiest way to make HTTP requests via a proxy. The below shows an example of making a geocoding request:

 

<?php

function lookup($string){
  $quotaguard_env = getenv("QUOTAGUARD_URL"); 
  $quotaguard = parse_url($quotaguard_env);

  $proxyUrl = $quotaguard['host'].":".$quotaguard['port'];
  $proxyAuth = $quotaguard['user'].":".$quotaguard['pass']; 
 
   $string = str_replace (" ", "+", urlencode($string));
   $details_url = "http://maps.googleapis.com/maps/api/geocode/json?address=".$string."&sensor=false";
 
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $details_url);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_PROXY, $proxyUrl);
   curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
   curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyAuth);
   $response = json_decode(curl_exec($ch), true);
 
   // If Status Code is ZERO_RESULTS, OVER_QUERY_LIMIT, REQUEST_DENIED or INVALID_REQUEST
   if ($response['status'] != 'OK') {
    return null;
   }
 
   print_r($response);
   $geometry = $response['results'][0]['geometry'];
 
    $longitude = $geometry['location']['lng'];
    $latitude = $geometry['location']['lat'];
 
    $array = array(
        'latitude' => $latitude,
        'longitude' => $longitude,
        'location_type' => $geometry['location_type'],
    );
 
    return $array;
 
}
 
$city = 'San Francisco, USA';
 
$array = lookup($city);
print_r($array);
 
?>

  


If you have questions, or if this solution doesn’t work or fit your use case, please reach out to us at Support so we can help figure it out with you.


Working with sensitive data, like HIPAA, Financial, or Personally Identifiable Information (PII)? 
    Then you will want to check out our QuotaGuard Shield solution, it's the same as QuotaGuard Static, but with stronger end to end security for your requests. We can also help migrate current Static customers to Shield for free, just reach out to us at Support to request assistance.