中英翻译、歌词、藏头诗、智能聊天
$ w5 F% J2 F9 Z+ r此章接口都来源于:http://api.ajaxsns.com/ ,感谢作者的无私奉献。 ) t3 }% `5 X, [& s
9 y- q" s. B+ I6 p* T先看效果图# K6 Y: j& M4 V! b
5 h: ?0 w$ W& t& A* o! S6 h
- y& G+ s$ y% g! `2 f9 c% t6 v( w& C/ n# C, R( D
# D9 e4 {$ m3 S- a代码如下:
, R! M0 s' a0 t$ \. ]. J; N" y
- G% d2 i% G4 i7 A! N0 D# P7 R1、共同方法- 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 y% T( l x$ N: \1 Y; [# j& }7 C
复制代码
5 L0 U# y1 W: X
1 l+ Z# d4 |3 l7 N, o, `5 t b, R2、其他实现- //中英互译
- 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);
- } b1 q8 [0 |7 {) ~9 K/ ?; i
( s4 J- Q0 t/ R f6 N3 G
|
上一篇:微信三、歌曲点播下一篇:五、天气,在线计算、域名查询、ip归属、手机号
|