늘맑음

slack webhook 관련 자료

curl로 연동하는 부분 입니다.

[code]

$data = array(
   'channel'     => $slack->channel,
   'username'    => $slack->username,
   'text'        => $message['body'],
   //'icon_emoji'  => $icon,
   //'attachments' => $attachments
);

echo "--- pass --->>" . PHP_EOL;
echo print_r($data, true) . PHP_EOL;

$data_string   = json_encode($data);
$ch = curl_init($slack->slack_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
   'Content-Type: application/json',
   'Content-Length: ' . strlen($data_string))
);
$result = null;
try {
   //Execute CURL
   $result = curl_exec($ch);
} catch(\Exception $e) {
}

[/code]

|

댓글 1개

좋은정보 감사합니다.
댓글을 작성하시려면 로그인이 필요합니다. 로그인

개발자팁

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
JavaScript 6년 전 조회 2,078
JavaScript 6년 전 조회 2,159
PHP 6년 전 조회 2,155
기타 6년 전 조회 2,971
JavaScript
[JavaScript]
6년 전 조회 2,118
JavaScript 6년 전 조회 2,313
jQuery 6년 전 조회 2,138
PHP 6년 전 조회 2,793
기타 6년 전 조회 2,631
PHP 6년 전 조회 4,712
기타 6년 전 조회 2,147
정규표현식 6년 전 조회 2,370
정규표현식 6년 전 조회 2,729
웹서버 6년 전 조회 4,202
PHP 6년 전 조회 2,587
PHP 6년 전 조회 3,243
MySQL 6년 전 조회 4,192
jQuery 6년 전 조회 3,673
node.js 6년 전 조회 2,724
node.js 6년 전 조회 2,460
node.js 6년 전 조회 2,690
node.js 6년 전 조회 2,675
node.js 6년 전 조회 2,429
node.js 6년 전 조회 2,577
node.js 6년 전 조회 2,324
node.js 6년 전 조회 2,308
node.js 6년 전 조회 2,778
node.js 6년 전 조회 1,908
node.js 6년 전 조회 2,037
node.js 6년 전 조회 2,496
🐛 버그신고