如果我输出 "计算机" 地址如下
http://translate.google.com/translate_a/t?client=t&text=%BC%C6%CB%E3%BB%FA&sl=zh_CN&tl=en可以看到结果是{"sentences":[{"trans":"Computer","orig":"计算机","translit":""}],"dict":[{"pos":"名词","terms":["computer"]}],"src":"zh-CN"}
我想获取返回结果是Computer
请问php怎么做!
如输入a.php
看到的结果是Computer就可以了用file_get_contents()获取不到!有的还乱码。高手可以试试!无奈了,来求助!
谢谢

解决方案 »

  1.   

    我试过file_get_contents的确乱码,搞了一阵子还是没解决,用curl也一时没找到解决方法。
    不过在前台用ajax方式还是很简单的。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title> new document </title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="generator" content="editplus" />
    <meta name="author" content="JnKc" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
    </head>
    <body>
    <input type="text" name="text" value="计算机" /><button type="button">翻译</button><br />
    <input type="text" name="trans" />
    <script type="text/javascript">
    var gg = 'http://translate.google.com/translate_a/t?client=t&sl=zh_CN&tl=en';
    $('button').click(function(){
    $.getJSON(gg,{text:$('input[name=text]').val()},function(data){
    $('input[name=trans]').val(data.sentences[0].trans);
    });
    });
    </script>
    </body>
    </html>
      

  2.   

    多谢各位的帮忙-------------------------------------------------------
    绿色php资源 http://www.phpzy.com