infinityxtech/slack-api-php
最新稳定版本:v1.0.1
Composer 安装命令:
composer require infinityxtech/slack-api-php
包简介
A PHP client for the Slack API.
README 文档
README
This repository contains PHP classes for interacting with the Slack API. Below are links to documentation for each class:
- Slack Apps API Methods
- Slack Auth API Methods
- Slack Channel API Methods
- Slack Chat API Methods
- Slack Conversations API Methods
- Slack Files API Methods
- Slack Reactions API Methods
- Slack Reminders API Methods
- Slack Teams API Methods
- Slack User API Methods
- Slack User Groups API Methods
- Slack Views API Methods
SlackAuthProvider and SlackApiProvider Usage
To interact with the Slack API, you'll need to use the SlackAuthProvider and SlackApiProvider classes. Here's how you can set up and use them:
use SlackApi\Auth\SlackAuthProvider; use SlackApi\Core\SlackApiProvider; $clientId = getenv('SLACK_CLIENT_ID'); $clientSecret = getenv('SLACK_CLIENT_SECRET'); $redirectUrl = getenv('SLACK_REDIRECT_URL'); $provider = new SlackAuthProvider($clientId, $clientSecret, $redirectUrl); // Call this when you wish to redirect user to authorize with slack $provider->redirect(); // Call this on $redirectUrl when slack authorization redirect to $redirectUrl $token = $provider->getAccessToken($_GET['code']); // Create a new SlackApiProvider instance with access token $slackApi = new SlackApiProvider($token); // Below this point, you can use various API methods: $slackApi->channel()->someMethod(); $slackApi->user()->someMethod(); $slackApi->chat()->someMethod(); $slackApi->auth()->someMethod(); $slackApi->apps()->someMethod(); $slackApi->conversations()->someMethod(); $slackApi->files()->someMethod(); $slackApi->reactions()->someMethod(); $slackApi->reminders()->someMethod(); $slackApi->teams()->someMethod(); $slackApi->userGroups()->someMethod(); $slackApi->views()->someMethod();
Please replace the placeholders (SLACK_CLIENT_ID, SLACK_CLIENT_SECRET, SLACK_REDIRECT_URL) with your actual Slack app details. The redirectUrl must also be set within your Slack app configuration. After successful authentication and being redirected to the callback URL, you can obtain the access token.
You can then use the $slackApi instance to interact with various API methods from different classes within the repository.
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-23