늘맑음

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개

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

개발자팁

5,403건

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

+
분류 제목 글쓴이 날짜 조회
PHP 19-06-24 조회 3,212
PHP 19-06-09 조회 3,831
MySQL 19-04-01 조회 4,886
jQuery 19-03-20 조회 4,272
node.js 19-02-12 조회 3,374
node.js 19-02-12 조회 3,115
node.js 19-02-12 조회 3,375
node.js 19-02-07 조회 3,346
node.js 19-02-07 조회 3,090
node.js 19-02-07 조회 3,227
node.js 19-02-04 조회 2,972
node.js 19-02-04 조회 2,946
node.js 19-02-04 조회 3,390
node.js 19-01-31 조회 2,496
node.js 19-01-31 조회 2,651
node.js 19-01-31 조회 3,124
node.js 19-01-28 조회 2,912
node.js 19-01-28 조회 2,978
node.js 19-01-28 조회 2,818
node.js 19-01-22 조회 3,167
node.js 19-01-22 조회 2,904
node.js 19-01-22 조회 3,361
node.js 19-01-16 조회 2,779
node.js
[node.js]
19-01-16 조회 2,673
node.js 19-01-16 조회 9,353
node.js 19-01-12 조회 4,425
node.js 19-01-12 조회 3,049
node.js 19-01-12 조회 3,171
node.js 19-01-11 조회 2,718
node.js 19-01-11 조회 4,077