4 * Description of GoogleTranslate
9 require_once 'Pman.php';
10 class Pman_Core_GoogleTranslate extends Pman
16 $au = $this->getAuthUser();
18 $this->jerrAuth("only authenticated users");
21 $this->authUser = $au;
30 $pc = HTML_FlexyFramework::get()->Pman_Core;
31 if (empty($pc['googlekey'])) {
32 $this->jerr("Google API Key not configured");
35 $apiKey = $pc['googlekey'];
37 $text = 'Hello world!';
39 'key' => $pc['googlekey'],
40 'q' => rawurlencode($_REQUEST['text']),
41 'source' => $_REQUEST['src'],
42 'target' => $_REQUEST['dest']
45 $url = 'https://www.googleapis.com/language/translate/v2?key='.
49 '&source=en&target=fr';
51 $handle = curl_init($url);
52 curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
53 $response = curl_exec($handle);
54 $responseDecoded = json_decode($response, true);