Download the PHP package lfphp/wechatsdk without Composer

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

微信API SDK库

1. 安装

本SDK目前仅支持composer安装,如需其他安装方式,请自行下载相应库代码改造。

安装:

2. 公众号开发环境配置

2.1 配置基本域名信息

进入【设置与开发】 > 【账号设置】 > 【功能设置】,配置业务相关域名信息,包括:

2.2 配置技术相关参数

进入 mp.weixin.qq.com ,访问【设置与开发】 > 【开发接口管理】 菜单。

2.3 验证服务器地址

假设服务器地址(URL)配置为:https://www.site.com/callback.php,则在 callback.php 代码中实现服务器校验代码示例为:

3. 接收处理微信回调

3.1 获取回调数据

在上述处理响应代码中,继续追加正常微信回调业务代码:

上述代码中 $data 即为微信回调数组,详细格式请参考 微信开发文档

3.2 转换为事件对象

本SDK库封装常规事件对象,方便在实际代码中调用判断。以下示例仅以普通文本消息为例

4. 获取 access_token js_ticket page_access_token

公众号后端接口调用基本都依赖 access_token,应用需要获取 access_token 保存到本地,并定期刷新 access_token (一般有效期为 7200 s) 应用H5页面js调用接口需要 js_ticket 信息(一般有效期为7200s),应用需要获取并刷新该 js_ticket 微信环境H5 oAuth方式登录依赖页面page_access_token(不是后端接口的access_token)

4.1 获取 access_token

4.2 获取 js_ticket

4.3 获取 page_access_token

需要微信oAuth登录流程获取微信返回code,才能获取并使用 page_access_token, 具体请见 步骤5

5. 后端请求公众号接口

以获取公众号分享二维码为例,其他功能请参考 Service 下个类库方法

6. 页面oAuth鉴权流程

微信页面登录流程示意:

以下为各个关键环节代码示意。

【2】判断是否微信H5环境:

【3】构建登录鉴权URL,并跳转:

【6】解析微信登录回调数据

7. 前端JS调用

前端JS调用微信前端能力,需要通过步骤3.2 获取到可用 js_ticket

7.1 前端微信JSSDK初始化

前端初始化代码如下:

7.2 前端微信接口调用

在上一步前端初始化代码后,可通过 wx.ready() 方法判断是否初始化完成,完成后可以调用相应微信前端接口 以下仅以微信分享来举例:

8. 其他场景应用

  1. 公众号扫码订阅方式登录 //todo

All versions of wechatsdk with dependencies

PHP Build Version
Package Version
Requires ext-json Version *
ext-curl Version *
ext-simplexml Version *
ext-mcrypt Version *
ext-libxml Version *
lfphp/logger Version ^2.0
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 lfphp/wechatsdk contains the following files

Loading the files please wait ....