My PHP script is posting to another script.
Here is my current code:
$text = $_POST["text"];
//str_replace("\r\n",",",$text);
$text = preg_replace('/\r\n/',',',$text);
$text = urlencode($text);
$langpair = urlencode($_POST["langpair"]);
$hl = urlencode($_POST["hl"]);
$ie = urlencode($_POST["ie"]);
$oe = urlencode($_POST["oe"]);
$post_string = 'text='.$text.'&langpair='.$langpair.'&hl='.$hl.'&ie='.$ie.'&oe='.$oe.'&';
$handle = fopen("http://translate.google.com/translate_t?$post_string", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
}
fclose($handle);
}
$splits=split("<textarea name=q rows=5 cols=45 wrap=PHYSICAL>",$buffer);
$splits=split("</textarea>",$splits[1]);
$result=$splits[0];
$outputstring = str_replace(",","\r\n",$result);
$outputfile = fopen("output/translated.txt", "w");
fwrite($outputfile, $outputstring);
echo "Finished. File saved at <a href=\"output/translated.txt\">this location</a>";
It grabs a list I provide from my page, passes it to Google's translator, and then grabs the results. The issue is that it passes to the Google translator through URL which severely limits the amount of data that can be passed.
I need my script to post to the translator through a POST itself.