Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fintech-systems/slack-php-api
Laravel friendly PHP API for Slack
https://github.com/fintech-systems/slack-php-api
Last synced: about 2 months ago
JSON representation
Laravel friendly PHP API for Slack
- Host: GitHub
- URL: https://github.com/fintech-systems/slack-php-api
- Owner: fintech-systems
- License: mit
- Created: 2021-10-25T05:55:42.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-13T09:11:33.000Z (about 3 years ago)
- Last Synced: 2024-11-17T13:11:33.752Z (2 months ago)
- Language: PHP
- Size: 88.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Slack API
![GitHub release (latest by date)](https://img.shields.io/github/v/release/fintech-systems/slack-php-api) [![Build Status](https://app.travis-ci.com/fintech-systems/packagist-boilerplate.svg?branch=main)](https://app.travis-ci.com/fintech-systems/slack-php-api) ![GitHub](https://img.shields.io/github/license/fintech-systems/slack-php-api)A Slack API designed to run standalone or as part of a Laravel Application
Requirements:
- PHP 8.0
- A Slack App# Usage
## References
- https://www.tyntec.com/docs/whatsapp-business-api-integration-slack
-- Description on setting up the Slack Bot Token
- https://api.slack.com/methods/chat.postMessage
-- Description on how to set up the Slack User Token
- Difference bot and user tokens?
-- https://api.slack.com/authentication/token-types#user
--- xoxp = user token, xoxb = bot token## Framework Agnostic PHP
```php
load();$server = [
'bot_token' => $_ENV['SLACK_BOT_TOKEN'],
'user_token' => $_ENV['SLACK_USER_TOKEN'],
'channel' => $_ENV['SLACK_CHANNEL'],
];$api = new Slack($server);
```
## Laravel Installation
You can publish the config file with:
```bash
php artisan vendor:publish --provider="FintechSystems\Slack\SlackServiceProvider" --tag="slack-config"
```This is the contents of the published config file:
This is the contents of the published config file:
```php
return [
'bot_token' => env('SLACK_BOT_TOKEN'),
'user_token' => env('SLACK_USER_TOKEN'),
'channel' => env('SLACK_CHANNEL'),
];
```## Usage
### Example
```php
use FintechSystems\LaravelApiHelpers\Api;
$api = new Api();
$postData = [
'channel' => 'C02G5QS8ANA',
'text' => '*Joe Smith*/27823096710: how are you',
'thread_ts' => '1635100445.007500',
];$result = $api->postMessage($postData);
```### Methods
```php
public function postMessage(String $postFields)
public function makeImagePublic($id)
public function reconstructImageUrl($filesZero)
```## Testing
```bash
vendor/bin/pest
```### Local Development
If you are debugging from another package on localhost, then add this to `composer.json`:
```json
"repositories" : [
{
"type": "path",
"url": "../slack-php-api"
}
]
```Then in `require` section:
```json
"fintech-systems/slack-php-api": "dev-main",
```
## ChangelogPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Feel free to log an issue or create a pull request.
## Credits
- [Eugene van der Merwe](https://github.com/eugenevdm)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.