Download the PHP package hsinlu/wechat without Composer

On this page you can find all versions of the php package hsinlu/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 wechat

wechat

wechat

开发的微信公众平台 SDK,旨在于提供简洁优雅的开发体验。

暂不推荐于生产环境

功能

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

环境要求

PHP 版本 >=5.5.9

注意事项

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

安装

使用composer安装

使用

配置

在实例化类时传入微信相关的配置。

被动接收消息

被动接收普通消息

被动接收普通消息只需要绑定对应消息类别的处理程序,其中普通消息类别对应为:文本消息(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,您也可以根据需要扩展消息的类型

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

调用微信接口

获取access token

getAccessToken()

getAccessToken方法会优先从缓存中获取access token,缓存时间为100分钟,如果检测到缓存中不存在access token或者缓存过期,将会从微信服务器中重新获取。


forgetAccessToken()

该方法会移除缓存中的access token,下次获取access token将从微信服务器中重新获取。

获取微信服务器IP地址

getCallbackIP()

getCallbackIP方法获取微信服务器IP地址列表。

客服消息

addKFAccount()

addKFAccount方法用于添加客服账号。


modifyKFAccount()

modifyKFAccount方法用于修改客服账号


deleteKFAccount()

deleteKFAccount方法用于删除客服账号


uploadKFAccountAvatar()

uploadKFAccountAvatar方法用于设置客服账号的头像


getAllKFAccount()

getAllKFAccount用于获取所有客服账号


sendKFMessage()

sendKFMessage用于发送客服消息

群发消息

uploadNews()

uploadNews方法用于上传图文消息素材


massSendByGroup()

massSendByGroup方法用于给分组群发消息。


All versions of wechat with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
guzzlehttp/guzzle Version ^6.1
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/wechat contains the following files

Loading the files please wait ....