Jump to content
Chinese-Forums
  • Sign Up

Tencent qq (Chinese icq)


tetsuo500

Recommended Posts

Google has a translation section? I know altavista has one... babelfish...

Its still slow.. I think its the website. Its " too" heavy for my connection.

sending queries aint that hard :P I hacked a SMS service once :D. But the securcity was really crap

Link to comment
Share on other sites

you want the php code to interface the google translator? OK, here is the code that you will need:

/**

* Get a remote file using POST

*

* $url String The url which locates the server, port number, and file.

* $_query String The dat to be sent with the header

* returns String the body of the file if successfull

*/

function fetchURL( $url, $_query ) {

$url_parsed = parse_url($url);

$host = $url_parsed["host"];

$port = $url_parsed["port"];

if ($port==0)

$port = 80;

$path = $url_parsed["path"];

$out = "POST $path HTTP/1.0rn";

$out .= "Host: $hostrn";

$out .= "Content-length: " . strlen($_query) . "rnrn";

$out .= $_query . "rn";

$fp = fsockopen($host, $port, $errno, $errstr, 30);

fwrite($fp, $out);

$body = false;

while (!feof($fp)) {

$s = fgets($fp, 1024);

if ( $body )

$in .= $s;

if ( $s == "rn" )

$body = true;

}

fclose($fp);

return $in;

}

/**

* Tranlate English to Chinese (GB2312)

* Uses http://translate.google.com/translate_t

*

* $text String The English to be translated

* returns String Chinese (GB2312) translated from $text

*/

function translateEnglishToChinese( $text ) {

$data = fetchURL("http://translate.google.com/translate_t", "text=$text&langpair=en%7Czh-CN");

list($junk, $data) = split('<textarea name=q rows=5 cols=45 wrap=PHYSICAL>', $data);

list($translation, $junk) = split('</textarea>', $data);

return $translation;

}

/**

* Tranlate Chinese (GB2312) to English

* Uses http://translate.google.com/translate_t

*

* $text String The Chinese (GB2312) to be translated

* returns String English translated from $text

*/

function translateChineseToEnglish( $text ) {

$data = fetchURL("http://translate.google.com/translate_t", "text=$text&langpair=zh-CN%7Cen");

list($junk, $data) = split('<textarea name=q rows=5 cols=45 wrap=PHYSICAL>', $data);

list($translation, $junk) = split('</textarea>', $data);

return $translation;

}

Link to comment
Share on other sites

Does anyone have a problem with sending messages through QQ? Tonight, when I tried to send messages, I kept getting something like this:

Last sent message: ": " failed to send(server timeout).

I'm in the United States. Any clue what's going on?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...