| 
 | 
 
在论坛找了好久,发现微信相关的库比较少,而且功能都要自己去扩展,而github和开源中国社区的类库又都要改动不少地方才能适配CI框架,于是今天终于自己动手然后综合了几个开源类库的一些方法完善了它,在些分享,新人发贴,希望指教。。。。。。 
主要代码来源:https://github.com/dodgepudding/wechat-php-sdk 
 
进入正题 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
使用方法: 
其实类的最上方有的,方便用的时候可以看一下 
 
控制器代码 
PHP复制代码  
<?php
defined('BASEPATH') OR  exit('No direct script access allowed');
//include("../wechat.class.php");
class Test  extends CI_Controller  {
 
 
public function __construct () {
                parent ::__construct ();
                        $params = array(
                                'token'=>'weixin', //填写你设定的key
                                'encodingaeskey'=>'encodingaeskey', //填写加密用的EncodingAESKey
                                'appid'=>'ddfgggffrff01add', //填写高级调用功能的app id
                                'appsecret'=>'39ea2b********************' //填写高级调用功能的密钥
                        );
                 //这个$params必须在构造函数传参,因为类库在构造函数中$this->appid = isset($params['appid'])?$params['appid']:'';
                $this->load->library('wechat/wechat',$params);
            }
            
        public function index  (){
                $this->wechat->valid();
                $type=$this->wechat->getRev()->getRevType();
                switch($type) {
                        case Wechat ::MSGTYPE_TEXT:
                                $this->wechat->text("hello, I'm 文本")->reply();
                                exit;
                                break;
                        case Wechat ::MSGTYPE_EVENT:
                                $this->wechat->text("hello, 我是事件")->reply();
                                exit;
                                break;
                        case Wechat ::MSGTYPE_IMAGE:
                                $this->wechat->text("hello, I'm 图片")->reply();
                                exit;
                                break;
                        default:
                                $this->wechat->text("我是未知")->reply();
                }
        }
 
}
   复制代码 
具体的方法自己研究! 
 |   
 
 
 
 |