PHP Wechat SDK -- Zebra-Wechat-php Tutorial

Source: Internet
Author: User
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 ();

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.