Download the PHP package hsinlu/laravel-wechat without Composer

On this page you can find all versions of the php package hsinlu/laravel-wechat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-wechat

wechat

wechat

基于 laravel5.1 开发的微信公众平台 SDK,支持管理多个微信应用,旨在于提供简洁优雅的开发体验。

暂不推荐于生产环境

功能

以下是所支持的功能列表,根据微信官方文档分类、命名,其中打勾的为已完成功能,其他为开发中状态。

环境要求

PHP 版本 >=5.5.9

注意事项

  1. 所有发往微信的json数据,如果包含中文,在使用json_encode时,需要设置JSON_UNESCAPED_UNICODE

安装

使用composer安装
配置laravel项目
  1. Hsin\Wechat\WechatServiceProvider 添加到laravel项目 config/app.php

  2. Hsin\Wechat\Http\Middleware\CheckWechatSignature 配置到laravel项目 app/Http/Kernel.php

  3. /wechat/* 请求路径加入到中间件 App\Http\Middleware\VerifyCsrfToken 排除列表

  4. 最后执行 vendor:publish 将配置文件和其他资源文件拷贝到 laravel 项目对应的目录

使用

配置

config/wechat.php 中配置微信应用的相关参数,如果有多个应用,复制 apps 数组第一个应用配置并更改相关的配置项。

通过 wechat() 方法生成默认的微信应用(默认为配置中的第一个),通过 wechat('应用的唯一标识')生成其他微信应用。

微信接入

SDK中提供了 wechat/access 路由供应用接入使用,如果您的域名是 http://hsinlu.com,那么您在微信中配置的服务器地址则是 http://hsinlu.com/wechat/access

对于多个应用,配置的服务器地址则需要在 wechat/access 之上添加应用的唯一标识,如 http://hsinlu.com/wechat/access/wx1d3e8db24427e3a6,SDK 在收到微信推送的消息时,会根据应用的唯一标识,来判断是哪个应用。

被动接收消息

被动接收普通消息

被动接收消息处理策略写在 app/Wechat/strategy.php 文件。

被动接收普通消息只需要绑定对应消息类别的处理程序,其中普通消息类别对应为:文本消息(text)、图片消息(image)、语音消息(voice)、视频消息(video)、小视频消息(shortvideo)、地理位置消息(location)、链接消息(link),下面代码以文本消息(text)为例:

除了上面闭包形式的处理程序,您还可以设置单独的处理类,处理类需要包含 handle 方法。

被动接收事件消息

事件消息与普通消息的处理方式相同,唯一不同的是事件消息的处理程序的键值为消息类型+事件类型组成,其中事件消息的类型为event,事件类型包含以下几种:关注(subscribe)、取消关注(unsubscribe)、扫描带参数二维码事件(为关注时为subscribe,EventKey以qrscene_为前缀;已关注时为SCAN)、上报地理位置事件(LOCATION)、自定义菜单事件(CLICK)、点击菜单跳转链接时的事件(VIEW),下面以关注事件为例:

与普通消息一样,除了闭包形式的处理程序外,您仍可以设置单独类作为处理程序,与普通消息一致,这里不再示例。

回复消息的类型

回复消息的类型为微信预定义的几种消息格式,分别为:回复文本消息(text)、回复图片消息(image)、回复语音消息(voice)、回复视频消息(video)、回复音乐消息(music)、回复图文消息(news),当然,SDK中已经对此类的消息做了封装,无需手动生成响应的XML。

所有的消息结果类都继承抽象类Result,您也可以根据需要扩展消息的类型

所有的消息结果类构造函数接收一个包含消息类所需要的数据数组,以下以回复文本消息为例:

SDK中提供了wechat_result方法来帮助构建消息结果类,您仍可以使用new TextResult([])形式构建。

调用微信接口

请参见hsinlu/wechat


All versions of laravel-wechat with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 5.1.*
hsinlu/wechat Version ^0.0.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hsinlu/laravel-wechat contains the following files

Loading the files please wait ....