늘맑음

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,086
JavaScript 6년 전 조회 2,171
PHP 6년 전 조회 2,165
기타 6년 전 조회 2,984
JavaScript
[JavaScript]
6년 전 조회 2,128
JavaScript 6년 전 조회 2,327
jQuery 6년 전 조회 2,151
PHP 6년 전 조회 2,802
기타 6년 전 조회 2,643
PHP 6년 전 조회 4,726
기타 6년 전 조회 2,160
정규표현식 6년 전 조회 2,384
정규표현식 6년 전 조회 2,739
웹서버 6년 전 조회 4,214
PHP 6년 전 조회 2,601
PHP 6년 전 조회 3,255
MySQL 6년 전 조회 4,205
jQuery 6년 전 조회 3,691
node.js 6년 전 조회 2,736
node.js 6년 전 조회 2,475
node.js 6년 전 조회 2,703
node.js 6년 전 조회 2,688
node.js 6년 전 조회 2,445
node.js 6년 전 조회 2,593
node.js 6년 전 조회 2,340
node.js 6년 전 조회 2,316
node.js 6년 전 조회 2,788
node.js 6년 전 조회 1,915
node.js 6년 전 조회 2,045
node.js 6년 전 조회 2,508
🐛 버그신고