Download the PHP package vinlon/laravel-wechat-auth without Composer

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

Laravel Wechat Auth

更新日志

v0.4.0: 升级到laravel8.0, 增加手机号绑定接口 v0.3.0: wxapp/fast_login接口支持模拟登录,便于在开发环境进行测试

小程序登录

使用指引

  1. 引入package

  2. 发布config文件 (Laravel 版本 > 5.5)

    先执行如下命令

    在应用程序的config目录下,将生成wechat-auth.php文件(注:一般情况下,此文件不需要做任何修改,配置的调整通过环境变量实现)

  3. 环境变量

    配置小程序的APPID 和 APPSECRET

  4. 创建数据库表

  5. 生成JWT_SECRET

    生成JWT_SECRET, 并自动写入根目录下的.env文件

  6. 根据实际需要调用对应的接口

    详见接口说明

  7. 使用 auth middleware 对请求的登录状态进行验证

接口说明

fast_login

快速登录,小程序端不需要进行授权, 但对于新用户来说,用户表中只会记录openid, 如果需要用户昵称、头像等,需要调用 profile 接口提交用户信息

接口地址: wxapp/fast_login
请求方式:POST
INPUT:

参数 说明
code 微信客户端调用wx.login得到的code

OUTPUT:

参数 说明
access_token JWT Token, 具体使用方式见 [JWT Token 使用说明](#JWT Token 使用说明)
token_type Bearer
expires_in access_token有效期
user_info 字段命令和微信getUserInfo的返回值保持一致,如果
如果数据中未保存用户信息,则不包含此字段

注: 如果用户被禁用,则该接口将返回 401:Unauthenticated

示例

mobile

此接口需要在fast_login登录成功的情况下调用,保存用户微信绑定的手机号

接口地址:wxapp/mobile

请求方式: POST

参数 说明
code 微信客户端调用wx.login得到的code
encrypted_data wx.getUserInfo返回的数据,包括敏感数据在内的完整用户信息的加密数据
iv wx.getUserInfo返回的数据,加密算法的初始向量

OUTPUT: []

wxapp/profile

此接口一般在fast_login请求成功的情况下调用,直接将wx.getUserInfo中返回的用户信息(未加密)保存到服务器

参数 说明
nickName 用户昵称
country 国家
province 省份
city 城市
gender 性别,0:未知,1:男,2: 女
avatarUrl 用户头像地址

OUTPUT: []

JWT Token 使用说明

使用jwt-auth的验证方式, 详见

异常

WechatAuthException

事件

WxAppGuard 配置

下面的配置不需要手动设置,已经通过WechatAuthServiceProvider自动将配置添加到auth config中

引用

https://github.com/tymondesigns/jwt-auth
https://github.com/overtrue/laravel-wechat

参考

xiaohuilam/laravel-wxapp-login
为什么用jwt-auth而不是laravel/passport


All versions of laravel-wechat-auth with dependencies

PHP Build Version
Package Version
Requires tymon/jwt-auth Version 1.*
bensampo/laravel-enum Version ^3.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 vinlon/laravel-wechat-auth contains the following files

Loading the files please wait ....