Hi All,
I am submitting post on this subject and I am etting replies but the replies are not mush help, I am new'ish to php.
I need to connect to a service which is on a web server in the US.
I have tried a number of way but the results are not so good.
The script works but what I am trying to do is to display the resulting content in a html table. All that happen now is the result is displayed as a line of text.
How can I build in a table which can contain my own headers and footers.
I am not 100% sure what all the parts of the script do but I think that the "echo $str;" displays the result.
I hope the above is clear, please if you can help.
The script I am using is below
Regards
Dereck
<?php
$text = "I have a dog.";
translate($text, "en", "de"); //translated "i have a dog" from English to French
exit;
function translate($text, $srclang, $trglang)
{
$request = "GET /S301.1/api?wl_data=";
#must always urlencode parameter values that contain whitespace or other special characters
$request .= urlencode($text);
$request .= "&wl_errorstyle=1";
$request .= "&wl_srclang=$srclang&wl_trglang=$trglang&wl_password=mypassword HTTP/1.1\n";
$request .= "Accept-Charset: iso-8859-1\n";
$request .= "Host: www.mydomain.com\n";
$request .= "Connection: Keep-Alive\n\n";
$server = "www.mydomain.com";
$port = 80;
$socket = fsockopen($server, $port, &$errno, &$errstr);
fwrite($socket, $request);
echo "<html><body><pre>";
while (!feof($socket))
{
$str = fgets($socket, 99999);
echo $str;
}
fclose($socket);
echo "</pre></body></html>";
print("\n");
}
?>