Created
August 10, 2016 01:21
-
-
Save Echocage/bd21818faf5b2bc86a08fbe2f9e9fa93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$text = "this is test sentence to see if this works"; | |
$source = "auto"; | |
$target = "pl"; | |
$regex = '/"([^+,+$]+)"/'; | |
$textEncode = urlencode($text); | |
$response = file_get_contents("http://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=$target&dt=t&q=$textEncode"); | |
$response = preg_replace('/,+/', ',', $response); | |
$response = preg_replace('/\[,/', '[', $response); | |
$responseArray = json_decode($response); | |
$response_text = $responseArray[0][0][0]; | |
print_r($response_text); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment