PHP微信SDK——Zebra-Wechat

PHP Jenner 11206℃ 0评论

Zebra-Wechat

Zebra-Wechat是微信公众平台开放接口的PHP封装,简单易用,支持以下功能:

  • 接收微信服务器推送信息,对推送信息类型进行识别
  • 微信API客户端封装(用户管理、用户组管理、客服管理、自定义菜单管理、系统管理等)
  • 微信跳转验证封装
  • 微小店相关接口

博客地址:www.huyanping.cn

接收微信推送示例

use \Jenner\Zebra\Wechat\WechatServer;
use \Jenner\Zebra\Wechat\Response\TextResponse;

$token = 'you wechat token';
$server = new WechatServer($token);
$server->on('before', function(WechatServer $server, $request){
    //do something
});
$server->on('after', function(WechatServer $server, $result){
    //do something
});
$server->on('unknown_message', function(WechatServer $server, $request){
    //do something
});
$server->on('unknown_event', function(WechatServer $server, $request){
    //do something
});
$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);
});

主动向微信发送消息

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();

 

更多,请关注https://github.com/huyanping/Wechat-PHP-Zebra,如果对您有帮助,希望给个star

原创文章,转载请注明: 转载自始终不够

本文链接地址: PHP微信SDK——Zebra-Wechat

转载请注明:始终不够 » PHP微信SDK——Zebra-Wechat

喜欢 (3)