阅读背景:

API实践:用百度翻译API写一个在线翻译

来源:互联网 

<pre name="code" class="php">php:
<?php
//Using baidu translate API
$content=urlencode($_GET["cont"]);
//$content="nihao";
$api="your apikeys";
$url="https://openapi.baidu.com/public/2.0/bmt/translate?client_id=$api&q=$content&from=auto&to=auto";
$str=file_get_contents($url);
$tmp=json_decode($str);
$con=$tmp->trans_result;//注意api返回的是对象 UI用我之前的ajax框架便可
echo $con[0]->dst;
?><pre name="code" class="php">php:
<?php
//Using ba




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: