欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

四、中英翻译、歌词、藏头诗、智能聊天

程序员文章站 2022-06-11 19:17:53
...
中英翻译、歌词、藏头诗、智能聊天
此章接口都来源于:http://api.ajaxsns.com/ ,感谢作者的无私奉献。

先看效果图
四、中英翻译、歌词、藏头诗、智能聊天
四、中英翻译、歌词、藏头诗、智能聊天
四、中英翻译、歌词、藏头诗、智能聊天

代码如下:

1、共同方法private function _ajaxsns_comm($msg){
$param=array(
"key" => "free",
"appid" => "0",
"msg" => "$msg"
);

$datas=http("http://api.ajaxsns.com/api.php",$param);
$json=json_decode($datas);
if($json->result==0){
$content=str_replace("{br}","\n",$json->content);
}else{
$content="从前有座山,山上有座庙,庙里有个小和尚,-^-,连接出错,请稍后再试,^_^.";
}
$content.="\n\n小助手:回复 @ 进入主界面";

return array($content,"text");
}
2、其他实现//中英互译
private function get_translate($find_name){
return $this->_ajaxsns_comm("翻译".$find_name);
}

//歌词
private function get_lyric($find_name){
return $this->_ajaxsns_comm("歌词".$find_name);
}
//藏头诗
private function get_poem($find_name){
return $this->_ajaxsns_comm("藏头诗".$find_name);
}

//智能多天
private function get_chat($find_name){
return $this->_ajaxsns_comm($find_name);
}
四、中英翻译、歌词、藏头诗、智能聊天

来源:http://www.xiuxiandou.com

AD:真正免费,域名+虚机+企业邮箱=0元