ソースコード
上記のスクリプトを Unity プロジェクトに追加します
(このクラスは Unity 5.3 以上で使用することができます)
使用例 1
var url = "【Webhook URL】"; var payload = new Payload { text = "ここにテキストを入力します", }; var routine = IncomingWebhooks.SendMessage( url, payload ); StartCoroutine( routine );
使用例 2
var url = "【Webhook URL】"; var payload = new Payload { text = "<http://baba-s.hatenablog.com/|ブログ>を表示します", }; var routine = IncomingWebhooks.SendMessage( url, payload ); StartCoroutine( routine );
使用例 3
var url = "【Webhook URL】"; var payload = new Payload { text = "おはよう!", username = "プロ生ちゃん", icon_url = "https://pbs.twimg.com/profile_images/734168776120270848/5R5uHOdP.jpg", }; var routine = IncomingWebhooks.SendMessage( url, payload ); StartCoroutine( routine );
使用例 4
var url = "【Webhook URL】"; var attachment = new Attachment { fallback = "エラーが発生したよ!", color = "#D00000", pretext = "エラーが発生したよ!", text = error, }; var payload = new Payload { username = "プロ生ちゃん", icon_url = "https://pbs.twimg.com/profile_images/734168776120270848/5R5uHOdP.jpg", attachments = new [] { attachment }, }; var routine = IncomingWebhooks.SendMessage( url, payload ); StartCoroutine( routine );
参考サイト様
Sending messages using Incoming Webhooks | Slack