Git Product home page Git Product logo

yii2-wechat's Introduction

yii2 wechat

yii2 wechat, yii2微信扩展。最适合yii2项目的微信sdk,不依赖任何其他微信sdk。

安装

  1. 使用composer composer的安装以及国内镜像设置请点击此处

    $ cd /path/to/yii2-app
    $ composer require "feehi/yii2-wechat"
    $ composer install -vvv

配置

yii2 wechat是作为一个组件提供服务的,所以得配置yii2 wechat组件。打开common/config/main.php在components块内增加

    'components' => [
        'wechat' => [
            'class' => feehi\wechat\Wechat::className(),
            'appId' => 'xxx',
            'appSecret' => 'yyy',
            'token' => 'zzz',
            'encodingAesKey' => 'bbb',
            'redirectUri' => 'site/login'//回调路由
        ],
    ]

核心API

    /** @var $wechat \feehi\wechat\Wechat */
    $wechat = yii::$app->get('wechat');
    
    $wechat->checkSignature(); //检验echoStr
    $wechat->getServerAccessToken(); //获取服务端access_token
    $wechat->createMenu(); //创建自定义菜单
    $wechat->getLoginUrl(); //获取微信登陆授权url
    $wechat->getAccessToken(); //获取用户access_token
    $wechat->getImplicitAccessToken(); //获取隐士授权用户的access_token
    $wechat->getUserInfo(); //根据用户access_token获取用户信息
    $wechat->createTempMedia(); //创建临时媒体素材
    $wechat->recieveWechatPush(); //接受微信推送的消息和事件
    $wechat->assembleWechatResponse(); //组装需要返回给微信的xml

P.S 以上基本上都是返回stdClass object,可以在ide中增加注释/** @var $wechat \feehi\wechat\Wechat */来跳转sdk源码。

yii2-wechat's People

Contributors

liufee avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

imlzg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.