2017 © Pedro Peláez
 

library wxxcx

A WeChat applet (xiaochengxu) plugins for Laravel 5.

image

vicleos/wxxcx

A WeChat applet (xiaochengxu) plugins for Laravel 5.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 2 Versions
  • 8 % Grown

The README.md

[laravel-wxxcx] package

Laravel 5 微信小程序插件, (*1)

备注

Api | 说明 | 对应方法 ---|---|--- wx.login | 登录 | $obj->getLoginInfo wx.getUserInfo | 获取用户信息 | $obj->getUserInfo($encryptedData,$iv); reference:https://mp.weixin.qq.com/debug/wxadoc/dev/api/, (*2)

安装

执行以下命令安装最新稳定版本:, (*3)

composer require vicleos/wxxcx

或者添加如下信息到你的 composer.json 文件中 :, (*4)

"vicleos/wxxcx": "1.*"

然后注册服务提供者到 Laravel中 具体位置:/config/app.php 中的 providers 数组:, (*5)

Vicleos\Wxxcx\WxxcxServiceProvider::class,

发布所需的资源(样式、视图、配置文件等):, (*6)

php artisan vendor:publish --provider="Vicleos\Wxxcx\WxxcxServiceProvider"

命令完成后,会添加一个wxxcx.php配置文件到您的配置文件夹 如 : /config/wxxcx.php。, (*7)

生成配置文件后,将小程序的 AppIDAppSecret 填写到 /config/wxxcx.php 文件中, (*8)

在Laravel 5控制器中使用 (示例)

...
use Vicleos\Wxxcx\Wxxcx;
...
class YourController extends Controller
{
    ...

    private function getWxxcx()
    {
        return new Wxxcx(config('wxxcx'));
    }

    /* 根据 code , encryptedData , iv 获取用户解密后的信息 */
    public function getWxUserInfo(Request $rq)
    {
        //使用 ajax 请求将获取的加密数据和参数发送到这里

        //code 在小程序端使用 wx.login 获取
        $code = $rq->input('code');
        //encryptedData 和 iv 在小程序端使用 wx.getUserInfo 获取
        $encryptedData = $rq->input('encryptedData');
        $iv = $rq->input('iv');

        //小程序类实例化
        $wxxcx = $this->getWxxcx();
        //根据 code 获取用户 session_key 等信息
        $wxxcx->getLoginInfo($code);
        //获取解密后的用户信息
        return $wxxcx->getUserInfo($encryptedData, $iv);
    }

    ...
}

reponse:, (*9)

{
    "openId": "xxxx",
    "nickName": "Vicleos",
    "gender": 1,
    "language": "zh_CN",
    "city": "Beijing",
    "province": "Beijing",
    "country": "CN",
    "avatarUrl": "http://wx.qlogo.cn/mmopen/vi_32/xxxx",
    "unionId": "xxxxx",
    "watermark": {
        "timestamp": 1465251521,
        "appid": "your appid"
    }
}

小程序端如何获取 wx.login() 中的 code

...
    wx.login({
        success: function (res) {
            console.log(res.code);
            //结果 "071A8Miq00onPq1BpUgq0NBPiq0xxxx"
        }
    })
...

The Versions

13/05 2017

dev-master

9999999-dev

A WeChat applet (xiaochengxu) plugins for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel wechat wxxcx xcx

10/05 2017

v1.0

1.0.0.0

A WeChat applet (xiaochengxu) plugins for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel wechat wxxcx xcx