承接 commandstring/discordoauth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

commandstring/discordoauth

最新稳定版本:v1.0.1

Composer 安装命令:

composer require commandstring/discordoauth

包简介

An easier way to use discord oauth in PHP

README 文档

README

An easier way to get discord OAuth tokens

Requirements

  • PHP 8.1=<
  • Composer 2
  • Registered Discord application

Getting Token

You will need to retrieve your discord application's client_id and client_secret. After retrieving those you can instantiate the \CommandString\DiscordOAuth\OAuth class.

$OAuth = (new OAuth("http://localhost:8000", $client_id, $client_secret));

You will then need to define scopes by using the addScopes method. You can either supply a scope string or supply a Scopes enum.

$OAuth->addScopes(Scopes::IDENTIFY);

Afterwards you can then generate a url for the authorize endpoint by invoking the buildAuthorizeUrl method.

$authUrl - $OAuth->buildAuthorizeUrl();

After the client is redirected you can then use the getToken method for retrieving the access token.

$tokenRes = $OAuth->getToken($_GET["code"]);

You can supply your own \React\Http\Browser in the second argument of this method

$tokenRes will be an stdClass with the following structure.

{
    "access_token": "<string>",
    "expires_in": "<int>",
    "refresh_token": "<string>",
    "scope": "<string>",
    "token_type": "<string>"
}

You can also refresh your token with the refreshToken method...

$newTokenRes = $OAuth->refreshToken($tokenRes->refresh_token);

Getting user

$user = User::getWithToken($tokenRes->token_type, $tokenRes->access_token);

Note: All properties of the user are readonly.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固