projects
/
Pman.Core
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
99f086c
)
GoogleTranslate.php
author
Chris
<chris@roojs.com>
Wed, 2 Apr 2014 10:10:53 +0000
(18:10 +0800)
committer
Chris
<chris@roojs.com>
Wed, 2 Apr 2014 10:10:53 +0000
(18:10 +0800)
GoogleTranslate.php
patch
|
blob
|
history
diff --git
a/GoogleTranslate.php
b/GoogleTranslate.php
index
8b4585e
..
df2704e
100644
(file)
--- a/
GoogleTranslate.php
+++ b/
GoogleTranslate.php
@@
-32,9
+32,6
@@
class Pman_Core_GoogleTranslate extends Pman
$this->jerr("Google API Key not configured");
}
$this->jerr("Google API Key not configured");
}
- $apiKey = $pc['googlekey'];
-
- $text = 'Hello world!';
$param = array(
'key' => $pc['googlekey'],
'q' => rawurlencode($_REQUEST['text']),
$param = array(
'key' => $pc['googlekey'],
'q' => rawurlencode($_REQUEST['text']),
@@
-42,11
+39,7
@@
class Pman_Core_GoogleTranslate extends Pman
'target' => $_REQUEST['dest']
);
'target' => $_REQUEST['dest']
);
- $url = 'https://www.googleapis.com/language/translate/v2?key='.
- $apiKey.
- '&q='.
- rawurlencode($text).
- '&source=en&target=fr';
+ $url = 'https://www.googleapis.com/language/translate/v2?'.http_build_query($param);
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
@@
-55,7
+48,7
@@
class Pman_Core_GoogleTranslate extends Pman
curl_close($handle);
curl_close($handle);
- $this->jdata($
key
);
+ $this->jdata($
responseDecoded
);
}
}