title: Google URLShortener API returns ipRefererBlocked
body: <p>I'm trying to use the Google URL shortener API with PHP:</p>
  
  <pre><code>$apiKey = 'ABC';
  $url = 'http://www.stackoverflow.com/';
  
  $postData = array('longUrl' =&gt; $url);
  $jsonData = json_encode($postData);
  
  $curlObj = curl_init();
  
  curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url?key=' . $apiKey);
  curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($curlObj, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($curlObj, CURLOPT_HEADER, 0);
  curl_setopt($curlObj, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8","Accept:application/json, text/javascript, */*; q=0.01"));
  curl_setopt($curlObj, CURLOPT_POST, 1);
  curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
  
  $result = curl_exec($curlObj);
  </code></pre>
  
  <p>But I'm getting the following error message:</p>
  
  <pre><code>{
      "error": {
          "errors": [{
              "domain": "usageLimits",
              "reason": "ipRefererBlocked",
              "message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
              "extendedHelp": "https://console.developers.google.com"
        }],
      "code": 403,
      "message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
  }
  </code></pre>
  
  <p>I've checked the following:</p>
  
  <ul>
  <li>That the referers are set (both http and https)</li>
  <li>That the API console registers all of the requests, but sadly as "client errors" and not as "success"</li>
  </ul>
  
  <p>The script is triggered whenever a user visits the page. </p>
  
  <p>I really appreciate any tip that helps me past this annoying problem. I don't seem to find any solution "out there".</p>