Last active
August 29, 2015 14:04
-
-
Save kidach1/1be27171c51283065aba to your computer and use it in GitHub Desktop.
[お手軽ChatOps] サーバサイドで起きた諸々の事象をSlackbotに通知してもらう ref: http://qiita.com/kidachi_/items/7f1053acb9dffc5c684d
This file contains 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
https://slack.com/api/chat.postMessage?channel=<channel_name>&text=<text>&token=<your_token>&username=<bot_name> |
This file contains 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
require 'addressable/uri' | |
require 'net/http' | |
endpoint = 'https://slack.com/api/chat.postMessage' | |
token='hogehoge' | |
channel='#slack_bot_test' | |
text='hello,slackbot!' | |
username='slackbot' | |
uri = Addressable::URI.parse(endpoint) | |
query = {token: token, channel: channel, text: text, username: username} | |
uri.query_values ||= {} | |
uri.query_values = uri.query_values.merge(query) | |
Net::HTTP.get(URI.parse(uri)) | |
=> "{\"ok\":true,\"channel\":\"C02EZTYKS\",\"ts\":\"1407134492.000010\"}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment