文章出處

不得不吐槽一下騰訊提供的官網開發文檔,真他媽跟屎一樣。

 

我的智商都需要反復看幾遍,還不懂。

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);
*/


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()