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");
36 'key' => $pc['googlekey'],
37 'q' => rawurlencode($_REQUEST['text']),
38 'source' => $_REQUEST['src'],
39 'target' => $_REQUEST['dest']
42 $url = 'https://www.googleapis.com/language/translate/v2';
44 $handle = curl_init();
45 curl_setopt($handle,CURLOPT_URL, $url);
46 // curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
47 curl_setopt($handle, CURLOPT_POST, count($param));
48 curl_setopt($handle, CURLOPT_POSTFIELDS, http_build_query($param));
49 $response = curl_exec($handle);
50 $responseDecoded = json_decode($response, true);
53 $this->jdata($responseDecoded);