Skip to content

Instantly share code, notes, and snippets.

@karia

karia/pukiwiki.cls.php

Last active Dec 21, 2015
Embed
What would you like to do?
<?php
/**
* PukiWiki Plus! notification for slack
*
* @copyright Copyright &copy; 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);
}
}
?>
@karia

This comment has been minimized.

Copy link
Owner Author

@karia karia commented Dec 21, 2015

下記項目は適宜変更ください。

  • $webhookurl
  • $data 内のicon_emoji に設定するemoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment