定制 iamprashant/slack-oauth2 二次开发

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

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

iamprashant/slack-oauth2

最新稳定版本:v1.2

Composer 安装命令:

composer require iamprashant/slack-oauth2

包简介

Slack OAuth 2.0 Client Provider for The PHP League OAuth2-Client

README 文档

README

This package is based on League's OAuth 2.0 Client with Slack v2 api.

Installation

$ composer require iamprashant/oauth2-slack

Usage

Usage is the same as The League's OAuth client, using \IamPrashant\OAuth2\Client\Provider\Slack as the provider.

Authorize Url generation

$provider = new \IamPrashant\OAuth2\Client\Provider\Slack([
    'clientId'          => '{client-id}',
    'clientSecret'      => '{client-secret}',
    'redirectUri'       => '{callback-url}',
]);
 
// to get authorization url
$authUrl = $provider->getAuthorizationUrl();


// if you need to request the user_scope also with global scope
$authUrl = $provider->getAuthorizationUrl(["user_scope"=>"users.profile:read,users:read.email,users:read,im:history"]);

// can request with global scope

$authUrl = $provider->getAuthorizationUrl(['scope' => 'user:read user:write file:write', "user_scope"=>"users.profile:read,users:read.email,users:read,im:history"]);

Authorization Flow

$provider = new \IamPrashant\OAuth2\Client\Provider\Slack([
    'clientId'          => '{client-id}',
    'clientSecret'      => '{client-secret}',
    'redirectUri'       => '{callback-url}',
]);

if (!isset($_GET['code'])) {

    // token requested
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);
    //  Token object will contains channels (if webhoooks enable) and team 
    try {
        // to get user details with complete informaiton
        $user = $provider->getResourceOwner($token);
        // Use these details to create a new profile
        var_dump($user);
    } catch (Exception $e) {
        // Failed to get user details
        exit('something got unexpected');
    }
 
    var_dump($token->getToken());
}

Contributing

Feel free to create pull request, Thanks for contributing.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固