늘맑음

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,176
JavaScript 6년 전 조회 2,232
PHP 6년 전 조회 2,228
기타 6년 전 조회 3,072
JavaScript
[JavaScript]
6년 전 조회 2,225
JavaScript 6년 전 조회 2,422
jQuery 6년 전 조회 2,233
PHP 6년 전 조회 2,881
기타 6년 전 조회 2,727
PHP 6년 전 조회 4,811
기타 6년 전 조회 2,256
정규표현식 6년 전 조회 2,479
정규표현식 6년 전 조회 2,825
웹서버 6년 전 조회 4,296
PHP 6년 전 조회 2,694
PHP 6년 전 조회 3,350
MySQL 6년 전 조회 4,286
jQuery 6년 전 조회 3,751
node.js 7년 전 조회 2,821
node.js 7년 전 조회 2,578
node.js 7년 전 조회 2,772
node.js 7년 전 조회 2,767
node.js 7년 전 조회 2,535
node.js 7년 전 조회 2,662
node.js 7년 전 조회 2,407
node.js 7년 전 조회 2,402
node.js 7년 전 조회 2,881
node.js 7년 전 조회 1,972
node.js 7년 전 조회 2,145
node.js 7년 전 조회 2,601