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

此章接口都来源于:http://api.ajaxsns.com/ ,感谢作者的无私奉献。 

先看效果图






代码如下:

   1、共同方法

   

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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、其他实现


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//中英互译
     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 );
     }


OK ,收工

查看来源

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值