title: What is wrong with this PHP cURL request to a Google API?
body: <p><strong>EDIT/UPDATE:</strong>
  1)  I tried the URL with just http (not https), and it worked in my browser.  But, it did not work with PHP and cURL!</p>
  
  <p>2)  I read the curl error message, and it said <code>Couldn't resolve host 'ajax.googleapis.com'</code>.  But, again, it <em>could</em> resolve the host from my web browser on the same machine!</p>
  
  <p>3) Google explicitly stated that I needed the CURLOPT_REFERER to be set, so I'm keeping it.</p>
  
  <p>Any other ideas?  Thanks!</p>
  
  <p><strong>ORIGINAL POST:</strong></p>
  
  <p>When I enter this URL into my web browser, I get the JSON response I want.  But, when I run the following cURL code in PHP5 (via Apache 2), the request fails.  Can anyone point to some possible problems?</p>
  
  <pre><code>$url = "https://ajax.googleapis.com/ajax/services/language/translate?v=1.0&amp;q=hola&amp;langpair=es%7Cen&amp;key=I-REMOVED-MY-API-KEY-FOR-STACKOVERFLOW-POST";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_REFERER, "http://my.ip.addr.ess/");
  $response = curl_exec($ch);
  var_dump($response);
  </code></pre>
  
  <p>The output is bool(false);</p>
  
  <p>I have no idea what's wrong... do you?  Thanks!</p>