php微信公众平台框架,wechat.php: 使用 PHP 编写的简洁微信公众平台服务器框架,简化微信公众平台服务端开发!...

Wechat.php

Wechat.php is an effort to create an elegant utility to interact with Server of Wechat Media Platform, in PHP. Wechat.php is designed to work well with modern PHP environment, including namespaces and composer. The API is strongly influenced by a fluent package written in Node.js, written in modern PHP syntax. We hope this collection of code could benefit anyone who works with an account of Wechat Media Platform.

The design of the library strictly follows the design of the Wechat Web API and provides functions/classes to facilitate your development. -- We do the painful things for you!

Installation

Though 'Wehcat.php' is designed to work with composer, the library is not yet uploaded and is under construction. Please add repository to your composer.json:

"repositories":[

{

"type":"vcs",

"url":"https://git.oschina.net/zhi/wechat.php.git"

}

]

Then add dependency:

"require":{

"yfwz100/wechat":"dev-master"

}

Example

use yfwz100\wechat as wechat;

// Do the verification and delegate requests to proper handlers.

wechat\Init::withToken('...YOUR TOKEN...');

$router = wechat\Router::get();

// Subscription event.

$router->event->on('subscribe', function () {

// use `echo` to output everything you want just like plain PHP.

// wechat\Reply class will generate the necessary XML for you.

echo wechat\Reply::text("Welcome subscribing~");

});

// click action is subsection of events.

$router->event->click->match('clicked', function ($matches) {

echo wechat\Reply::text("You've clicked 'clicked'!");

});

// Keyword reply.

$router->text->match('hello', function ($matches) {

echo wechat\Reply::text("Hello, world!");

});

Author

License

MIT.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值