Last active
December 21, 2015 16:14
-
-
Save karia/0964e6a1f71143cb65ac to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* PukiWiki Plus! notification for slack | |
* | |
* @copyright Copyright © 2011-2015, karia <karia@side2.net> Sho Sawada <s@shao.jp> | |
* @author karia <karia@side2.net> Sho Sawada <s@shao.jp> | |
* @version $Id: notify.cls.php,v 0.2 2015/12/21 00:15:00 upk Exp $ | |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License (GPL2) | |
*/ | |
class slack{ | |
function notice($msg, $editor_name){ | |
$webhookurl = 'https://hooks.slack.com/services/XXXX/XXXX/XXXXX'; | |
$data = array( | |
'payload' => '{"channel": "#general", "username": "'.$editor_name.'", "text": "PukiWikiからのお知らせだよ : '.$msg.'", "icon_emoji": ":alice_cartelet:"}' | |
); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $webhookurl); | |
curl_setopt($curl, CURLOPT_POST, TRUE); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); | |
$response = curl_exec($curl); | |
if ($response != 'ok') { | |
error_log('URL:'.$webhookurl); | |
error_log('data:'.$data(payload)); | |
error_log('response:'.$response); | |
} | |
curl_close($curl); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
下記項目は適宜変更ください。
$webhookurl
$data
内のicon_emoji
に設定するemoji