定制 jsanf/oauth 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jsanf/oauth

Composer 安装命令:

composer require jsanf/oauth

包简介

README 文档

README

install

composer require jsanf/oauth

config.php

return [
    'Wechat' => [
        'appid' => 'wxedfaa675aa',        //个人微信appid
        'secret'=> '0a4ab6706702585c043c3d70245',      
        'redirect_uri' => 'https://member-sso.pxo.cn/user/receive'  //回调地址
    ],
    'Wxwork' => [
        'agentid' => '1000170',
        'redirect_uri' => 'https://member-sso.pxo.cn/user/receive',     //回调地址

        //第三方应用
        'appid' => 'wwe394e1149a61',                                //suiteId
        'secret' => 'lQUGcC-5yScSKPGnheKuwB7CMCUOPk4ZM',      //suite_secret
        'token' => 'XPOLhzU227GemS',
        'EncodingAESKey' => '1QBd6iL5qKsjY0HsBA4vPtwBm8NSRz',

        //suite_ticket 缓存名称
        'suiteTicketCacheKey' => 'member:suite_ticket'
    ]
]

simple

    /**
     * 第三方登录
     */
    public function third()
    {
        $oauth = (new Oauth)->getInstance("Wechat", $config['Wechat'] ?? '');
        if(!$oauth) {
            echo "该登录方式不存在.";
            exit;
        }
        $param['return_url'] = $this->get['return_url'];
        $param['oauth_type'] = 'Wechat';
        //$param['scope'] = $this->get['scope'] ?? 'snsapi_base';
        $oauth->code($param);
    }

    /**
     * 第三方回调
     * @throws \GuzzleHttp\Exception\GuzzleException
     */
    public function receive()
    {
        $config = $config['Wechat'] ?? [];
        if(!$config) {
            echo 'oauth_type有误.';exit;
        }

        $config['return_data'] = $this->get;
        $oauth = (new Oauth)->getInstance('Wechat', $config);
        $userInfo = $oauth->userInfo();

        $token = $userInfo['openid'];

        //保存用户信息

        //缓存用户信息到redis缓存
        $this->redis::set('member:'.$token, $userInfo);

        header("Location:" . $_GET['return_url'] . '?token=' . $token);
    }

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固