2017 © Pedro Peláez
 

library wechat

WeChat plugin.

image

angel-project/wechat

WeChat plugin.

  • Friday, June 15, 2018
  • by ZimoTheDragon
  • Repository
  • 0 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 13 % Grown

The README.md

, (*1)

中文档案

Angel微信 是基于Angel框架的公众号开发框架, (*2)

安装

请先使用Composer安装Angel框架:, (*3)

composer create-project angel-project/framework .

然后安装微信拓展:, (*4)

composer require angel-project/wechat

GitHub php GitHub license, (*5)

公众号开发

一个基本的监听/反馈模板:, (*6)

  build::post('your/url',function(){

    $wx = new angel\wechat($appid,$secret,$token); //初始化微信object

    $wx->listen('text','hi',function($input,$wx){
      $wx->return('text',[
        'to' => $input->FromUserName,
        'content' => 'hello!'
      ]);
    }); //当用户输入hi时,返回字符串hello!

    $wx->listen('event','subscribe',function($input,$wx){
      $wx->return('news',[
        'to' => $input->FromUserName,
        'articles' => [[
          'title' => 'hi!',
          'description' => 'long time no see',
          'picurl' => 'yoururl.com/img.jpg',
          'url' => 'yoururl.com'
        ]]
      ]); //返回主题
    }); //当用户关注时触发,返回图文消息

    $wx->run(); //执行监听

  });

listen()方法有三个输入: - 监听方法:目前支持text(文字输入)、event(事件触发) - 触发事件:文字支持字符串和正则表达式匹配,事件支持SCAN(扫码)、subscribe(关注)、CLICK(点击)触发。当用户输入不满足任何规则时,当触发事件为'empty'。 - 触发后执行的代码:该function输入两个值:用户输入和微信object。你可以通过用户输入来获取所有用户传送至服务器的指令;微信object让你在function继续自由使用微信方法。, (*7)

创建菜单

  $wx = new angel\wechat($appid,$secret,$token); //初始化微信object

  $menu = [[
    'type' => 'click',
    'name' => '欢迎光临',
    'key' => 'welcome'
  ]]; //生成一个click时间菜单,具体创建菜单指令请参考微信开发者档案

  $at = $wx->access_token();  //获取access token
  $wx->menu($at,$menu); //生成菜单

English Doc

Angel WeChat is a WeChat plugin based on Angel Framework, (*8)

Installation

First, install Angel Framework with Composer using the following command:, (*9)

composer create-project angel-project/framework .

Then, install Angel WeChat package:, (*10)

composer require angel-project/wechat

GitHub php GitHub license, (*11)

The Versions

15/06 2018

dev-master

9999999-dev

WeChat plugin.

  Sources   Download

MIT

The Requires

  • php ^7.1.3

 

by Xiao Zimo

15/06 2018

v0.0.1

0.0.1.0

WeChat plugin.

  Sources   Download

MIT

by Xiao Zimo