定制 aimilink/hyperf-socialite 二次开发

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

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

aimilink/hyperf-socialite

最新稳定版本:3.0.4

Composer 安装命令:

composer require aimilink/hyperf-socialite

包简介

socialite

README 文档

README

About

Aimilink/hyperf-socialite 组件衍生于 cblink/hyperf-socialite 组件的,升级了组件版本。

Installing

# 安装
composer require Aimilink/hyperf-socialite -vvv

# 创建配置文件
php bin/hyperf.php vendor:publish Aimilink/hyperf-socialite

Configure

配置文件位于 config/autoload/socialite.php,如文件不存在可自行创建

<?php

return [
    // 需要加载的provider
    'providers' => [
        // \HyperfSocialiteProviders\Feishu\Provider::class,
    ],
    'config' => [
        'facebook' => [
            'client_id' => '',
            'client_secret' => '',
            // 其他provider中需要使用的配置
            // ...
        ],
        // qq,weixin...    ]()
    ],
    
];

Usage

组件已经提供了许多已支持的社会化登陆组件,只需要将它配置到 config/autoload/listeners.php 中即可。

return [
    HyperfSocialiteProviders\Facebook\FacebookExtendSocialite::class,
];

控制器中使用

<?php

use Aimilink\Hyperf\Socialite\Contracts\SocialiteInterface;

class Controller 
{
    
    /**
    * @param SocialiteInterface $socialite
     * @return \Hyperf\HttpServer\Contract\ResponseInterface
     */
    public function redirectToProvider(SocialiteInterface $socialite)
    {
        // 重定向跳转
       $redirect = $socialite->driver('facebook')->redirect();
       
       // 使用新的配置跳转
       $socialite->driver('facebook')->setConfig([
            'client_id' => 'xxx',
            'client_secret' => 'xxxx',
       ])  
       
       return $redirect; 
    }
    
    /**
    * @param SocialiteInterface $socialite
    */
    public function handleProviderCallback(SocialiteInterface $socialite)
    {
        // 获取用户信息
       $user = $socialite->driver('facebook')->user();
       
       //
       // $user->token;
    }


}

支持的列表

支持应用 驱动名称
微博 weibo
QQ qq
Facebook facebook
Instagram instagram
YouTube youtube
飞书自建应用 feishu
微信公众号 weixin
微信PC网站登陆 weixinweb
微信开放平台代公众号授权 wechat_service_account
企业微信第三方应用扫码 third_weworkqr
企业微信 wework
企业微信自建应用扫码 weworkqr

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-21