成功接入微信公众平台。

不得不吐槽一下腾讯提供的官网开发文档,真他妈跟屎一样。

 

我的智商都需要反复看几遍,还不懂。

http://blog.163.com/ppy2790@126/blog/static/1032422412014022493717/

这文章写的还好。总算明白了。

 

另外一个开源的sdk封装不错:

https://github.com/dodgepudding/wechat-php-sdk

 

使用方法:

/**
* 微信公众平台PHP-SDK, 官方API部分
* @author dodge <dodgepudding@gmail.com>
* @link https://github.com/dodgepudding/wechat-php-sdk
* @version 1.2
* usage:
* $options = array(
* 'token'=>'tokenaccesskey', //填写你设定的key
* 'encodingaeskey'=>'encodingaeskey', //填写加密用的EncodingAESKey
* 'appid'=>'wxdk1234567890', //填写高级调用功能的app id
* 'appsecret'=>'xxxxxxxxxxxxxxxxxxx' //填写高级调用功能的密钥
* );
* $weObj = new Wechat($options);
* $weObj->valid();
* $type = $weObj->getRev()->getRevType();
* switch($type) {
* case Wechat::MSGTYPE_TEXT:
* $weObj->text("hello, I'm wechat")->reply();
* exit;
* break;
* case Wechat::MSGTYPE_EVENT:
* ....
* break;
* case Wechat::MSGTYPE_IMAGE:
* ...
* break;
* default:
* $weObj->text("help info")->reply();
* }
*
* //获取菜单操作:
* $menu = $weObj->getMenu();
* //设置菜单
* $newmenu = array(
* "button"=>
* array(
* array('type'=>'click','name'=>'最新消息','key'=>'MENU_KEY_NEWS'),
* array('type'=>'view','name'=>'我要搜索','url'=>'http://www.baidu.com'),
* )
* );
* $result = $weObj->createMenu($newmenu);
*/

posted @ 2015-02-15 01:17    阅读(603)  评论(0编辑  收藏  举报
IT民工