接口功能完善的微信开发类库
在论坛找了好久,发现微信相关的库比较少,而且功能都要自己去扩展,而github和开源中国社区的类库又都要改动不少地方才能适配CI框架,于是今天终于自己动手然后综合了几个开源类库的一些方法完善了它,在些分享,新人发贴,希望指教。。。。。。主要代码来源:https://github.com/dodgepudding/wechat-php-sdk
进入正题
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
使用方法:
其实类的最上方有的,方便用的时候可以看一下
控制器代码
<?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();
}
}
}
具体的方法自己研究!
请问 微信配置token 如何配置啊 我老失败 请给个CI完整代码包 谢谢。
打开网页显示 An Error Was Encountered
Unable to load the requested class: session
class Wx extends CI_Controller
$this->load->library('wechat/wechat',$params);
$this->load->library('Wechat',$params); 我是这么写的才能找到 就是在liB目录
'encodingaeskey'=>'encodingaeskey', //填写加密用的EncodingAESKey 这个不知道用不用改 我没地方设置。
访问这个 xx.xxx.com/index.php/wx/index 微信公众号上配置这个URL 通不过 ,请告知如何配置。谢谢 censtart 发表于 2016-7-19 16:51
$this->load->library('wechat/wechat',$params);.好像应该是大写Wechat吧
是的装载类库注意大小写,谢谢指正 http://www.ifixedbug.com/posts/codeigniter-weixin-library
我封装的一个微信CI类库,用的和你一样的原生类库,逻辑转移到类库了,控制器很简单。 {:1_1:}thx 楼主,刚好最近在做微信业务 谢谢分享,学习了 感谢!!!非常感谢 $this->load->library('wechat/wechat',$params);.好像应该是大写Wechat吧 接口类中$_GET无法获取参数是什么原因? censtart 发表于 2016-7-19 19:09
接口类中$_GET无法获取参数是什么原因?
具体的,报了什么错? 谢谢分享 顺便问一下 CI框架的微信后台系统 有资源吗 谢谢
页:
[1]
2