title: Google's Translation API (REST) and PHP
body: <p>I want to translate words that has been send to the server from the client side. According to the documentation from Google you can use as follow:</p>
  
  <pre><code>GET https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&amp;source=en&amp;target=de&amp;q=Hello%20world
  </code></pre>
  
  <p>and it will respond with the following JSON object:</p>
  
  <pre><code>{
      "data": {
          "translations": [
              {
                  "translatedText": "Hallo Welt"
              }
          ]
      }
  }
  </code></pre>
  
  <p>I use the following in php:</p>
  
  <pre><code>$data = file_get_contents('https://www.googleapis.com/language/translate/v2?key=KEY8&amp;source=en&amp;target=ru&amp;q='.$to_be_translated);
  $data = json_decode($data);
  $translated = $data-&gt;translations-&gt;translatedText;
  </code></pre>
  
  <p>This does not work but if I use their JS example, then I do get the required result, therefore the translation setup is fine, the problem must be in my PHP script.</p>
  
  <p>I also tried:</p>
  
  <pre><code>$data = $_GET['https://www.googleapis.com/language/translate/v2?key=KEY8&amp;source=en&amp;target=ru&amp;q='.$to_be_translated];
  </code></pre>
  
  <p>but to no avail. Any suggestions?</p>