Created
January 8, 2020 23:57
-
-
Save ko31/a9cafcfc59d2db6af324aa6e75a6fb47 to your computer and use it in GitHub Desktop.
How to easily post to slack channel with PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Your slack token | |
| $token = 'YOURTOKEN'; | |
| // Your slack channel (e.g. #general) | |
| $channel = '#general'; | |
| // Post message | |
| $text = "<!channel>Hello World!"; | |
| $text = urlencode($text); | |
| $channel = urlencode($channel); | |
| $url = "https://slack.com/api/chat.postMessage?token={$token}&channel={$channel}&text={$text}"; | |
| file_get_contents($url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment