Skip to content

Instantly share code, notes, and snippets.

@ko31
Created January 8, 2020 23:57
Show Gist options
  • Select an option

  • Save ko31/a9cafcfc59d2db6af324aa6e75a6fb47 to your computer and use it in GitHub Desktop.

Select an option

Save ko31/a9cafcfc59d2db6af324aa6e75a6fb47 to your computer and use it in GitHub Desktop.
How to easily post to slack channel with PHP
<?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