Skip to content

Commit

Permalink
基本验证和消息收发
Browse files Browse the repository at this point in the history
  • Loading branch information
uicestone committed Jul 19, 2013
1 parent 515e2f2 commit 04c5a98
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
31 changes: 31 additions & 0 deletions application/controllers/weixin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
class Weixin extends SS_Controller{
function __construct() {
$this->permission=true;
parent::__construct();
}

function index(){

//验证
if($this->input->get('echostr')){
//TODO 需要对来源进行鉴别
$this->output->set_output($this->input->get('echostr'));
}

$this->load->addViewArrayData($this->input->post());

//消息推送
if($this->input->post('FromUserName')){
//文本消息
if($this->input->post('MsgType')==='text'){
$message=$this->input->post('content');
$this->load->view('weixin/reply_text');
}
}

}

}

?>
8 changes: 8 additions & 0 deletions application/views/weixin/reply_text.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<xml>
<ToUserName><?=$FromUserName?></ToUserName>
<FromUserName><?=$ToUserName?></FromUserName>
<CreateTime><?=time()?></CreateTime>
<MsgType>text</MsgType>
<Content>原样返回:<?=$content?></Content>
<FuncFlag>0</FuncFlag>
</xml>

0 comments on commit 04c5a98

Please sign in to comment.