dcjones
11-20-2003, 07:42 AM
Hi All.
This is my code:
<?php
$text = "I have a dog.";
translate($text, "en", "de");
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=password 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><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr>";
echo "<td width=\"100%>";
while (!feof($socket))
{
$str = fgets($socket, 99999);
echo $str;
}
echo "</td>";
echo "</tr>";
echo "</table>";
fclose($socket);
echo "</body></html>";
print("\n");
}
?>
If I run the code the output is :
<td width="100%>HTTP/1.1 200 Date: Thu, 20 Nov 2003 13:37:25 GMT Server: Apache Set-Cookie: mydomain.com=212.227.119.39.1069335445040508; path=/; expires=Tue, 18-Nov-08 13:37:25 GMT Set-Cookie: JSESSIONID=DDC55000894AE3CC60CDE78A86E4C6E1.tc2; Path=/ X-WL-ERRORCODE: 0 Content-Type: text/plain;charset=UTF-8 Content-Length: 21 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Ich habe einen Hund.
What I am trying to do is make the output display in the table.
Anyone know what is wrong. If you do please, I am a new php person.
If you can help me please
Regards, keep safe and well.
Regards
Dereck
This is my code:
<?php
$text = "I have a dog.";
translate($text, "en", "de");
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=password 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><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
echo "<tr>";
echo "<td width=\"100%>";
while (!feof($socket))
{
$str = fgets($socket, 99999);
echo $str;
}
echo "</td>";
echo "</tr>";
echo "</table>";
fclose($socket);
echo "</body></html>";
print("\n");
}
?>
If I run the code the output is :
<td width="100%>HTTP/1.1 200 Date: Thu, 20 Nov 2003 13:37:25 GMT Server: Apache Set-Cookie: mydomain.com=212.227.119.39.1069335445040508; path=/; expires=Tue, 18-Nov-08 13:37:25 GMT Set-Cookie: JSESSIONID=DDC55000894AE3CC60CDE78A86E4C6E1.tc2; Path=/ X-WL-ERRORCODE: 0 Content-Type: text/plain;charset=UTF-8 Content-Length: 21 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Ich habe einen Hund.
What I am trying to do is make the output display in the table.
Anyone know what is wrong. If you do please, I am a new php person.
If you can help me please
Regards, keep safe and well.
Regards
Dereck