늘맑음

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,081
JavaScript 6년 전 조회 2,164
PHP 6년 전 조회 2,158
기타 6년 전 조회 2,974
JavaScript
[JavaScript]
6년 전 조회 2,121
JavaScript 6년 전 조회 2,320
jQuery 6년 전 조회 2,145
PHP 6년 전 조회 2,799
기타 6년 전 조회 2,638
PHP 6년 전 조회 4,719
기타 6년 전 조회 2,155
정규표현식 6년 전 조회 2,377
정규표현식 6년 전 조회 2,735
웹서버 6년 전 조회 4,205
PHP 6년 전 조회 2,593
PHP 6년 전 조회 3,247
MySQL 6년 전 조회 4,199
jQuery 6년 전 조회 3,677
node.js 6년 전 조회 2,728
node.js 6년 전 조회 2,467
node.js 6년 전 조회 2,696
node.js 6년 전 조회 2,682
node.js 6년 전 조회 2,438
node.js 6년 전 조회 2,583
node.js 6년 전 조회 2,332
node.js 6년 전 조회 2,313
node.js 6년 전 조회 2,782
node.js 6년 전 조회 1,913
node.js 6년 전 조회 2,041
node.js 6년 전 조회 2,501
🐛 버그신고