PHPSDK -- Zebra-Wechat
The SDK is currently under development and has the following functions:
Receive server push information and identify push information types
API client encapsulation (user management, user group management, customer service management, custom menu management, system management, etc)
Redirect verification encapsulation
Card volume support
Blog address: www.huyanping.cn
Receive push example
Use \ Jenner \ Zebra \ Wechat \ WechatServer; use \ Jenner \ Zebra \ Wechat \ Response \ TextResponse; $ token = 'You wechat token '; $ server = new WechatServer ($ token); // call before processing an event, whether or not an event processor is registered $ server-> on ('before', function (WechatServer $ server, $ request) {// do something}); // call after processing the event, $ result is the returned value of the event processor $ server-> on ('after ', function (WechatServer $ server, $ result) {// do something}); // unknown message Processor $ server-> on ('unknown _ message', function (WechatServer $ server, $ request) {// do something}); // unknown time Processor $ server-> on ('unknown _ event', function (WechatServer $ server, $ request) {// do something}); // process text message push $ server-> on ('text', function (WechatServer $ server, $ request) {$ to_user = $ server-> getFromUserName (); $ from_user = $ server-> getToUserName (); $ response = new TextResponse ($ to_user, $ from_user, 'Hello '); $ server-> send ($ response) ;}); // process follow push $ server-> on ('subscribe', function (WechatServer $ server, $ request) {$ to_user = $ server-> getFromUserName (); $ from_user = $ server-> getToUserName (); $ response = new TextResponse ($ to_user, $ from_user, 'THX '); $ server-> send ($ response );});
Actively send messages
Define ('WeChat _ APP_ID ', 'Your app ID'); define ('WeChat _ secret', 'Your secret'); $ to_user = 'to _ user_open_id '; $ text = 'hello'; $ text_message = new \ Jenner \ Zebra \ Wechat \ Client \ Message \ TextMessage ($ to_user, $ text); $ text_message-> send ();