danielhe4rt/kick-php-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

danielhe4rt/kick-php-sdk

最新稳定版本:1.0.0

Composer 安装命令:

composer require danielhe4rt/kick-php-sdk

包简介

README 文档

README

Tests

Kick PHP SDK

A PHP SDK for interacting with the Kick.com API. This SDK provides a simple and intuitive way to authenticate with Kick's OAuth 2.0 implementation and interact with various Kick API endpoints.

Requirements

  • PHP 8.2 or higher
  • Composer

Installation

composer require danielhe4rt/kick-php-sdk

Usage

use DanielHe4rt\KickSDK\KickClient;

$clientId = 'your-client-id';
$clientSecret = 'your-client-secret';

$kickClient = new KickClient(
    clientId: $clientId,
    clientSecret: $clientSecret,
);

$redirectUrlDTO = RedirectUrlDTO::make(
    clientId: $clientId,
    redirectUri: 'http://localhost:8000/oauth/kick',
    responseType: 'code',
    scopes: [KickOAuthScopesEnum::USER_READ, KickOAuthScopesEnum::EVENTS_SUBSCRIBE],
    state: md5(time()),
);

echo $redirectUrlDTO->codeChallenge->getVerifier() . PHP_EOL;

$redirectUrl = $kickClient->oauth()->redirectUrl($redirectUrlDTO);

echo $redirectUrl . PHP_EOL;


echo "Paste the code you received in the redirect URL: ";
$code = trim(fgets(STDIN));

$authDTO = AuthenticateDTO::make(
    code: $code,
    codeVerifier: $redirectUrlDTO->codeChallenge->getVerifier(),
    redirectUrl: 'http://localhost:8000/oauth/kick',
);

$authToken = $kickClient->oauth()->authenticate($authDTO);

echo "Access Token: " . $authToken->accessToken . PHP_EOL;
echo "Refresh Token: " . $authToken->refreshToken . PHP_EOL;

$usersClient = $kickClient->users($authToken->accessToken);

$authenticatedUser = $usersClient->me();

echo "Authenticated User ID: " . $authenticatedUser->userId . PHP_EOL;
echo "Authenticated User Username: " . $authenticatedUser->username . PHP_EOL;
echo "Authenticated User Profile Picture: " . $authenticatedUser->profile_picture . PHP_EOL;
echo "Authenticated User Email: " . ($authenticatedUser->email ?? 'Not provided. See scopes') . PHP_EOL;

See examples for more usage examples. We also will be providing a Webhook handler soon.

Roadmap

  • Finish implementing all resources
  • Add comprehensive test coverage (90%+)
  • Add more examples and documentation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

统计信息

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

GitHub 信息

  • Stars: 30
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-17