LINE Messaging API의 Datetime picker action을 PHP로 사용
공식 SDK 업데이트 되었기 때문에 이제 이 처리는 불필요하게 되었습니다! 일단 남겨 둡니다만.
htps : // 기주 b. 코 m / ぃね / ぃねーぼ tsdk php
Datetime picker action.
htps : // v에서 cs. 네. 메/그럼/? ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ
오늘 사용할 것 같아서 올려 둡니다.
index.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
$httpClient = new \LINE\LINEBot\HTTPClient\CurlHTTPClient(getenv('CHANNEL_ACCESS_TOKEN'));
$bot = new \LINE\LINEBot($httpClient, ['channelSecret' => getenv('CHANNEL_SECRET')]);
$signature = $_SERVER["HTTP_" . \LINE\LINEBot\Constant\HTTPHeader::LINE_SIGNATURE];
$events = $bot->parseEventRequest(file_get_contents('php://input'), $signature);
foreach ($events as $event) {
if ($event instanceof \LINE\LINEBot\Event\PostbackEvent) {
error_log('postback : ' . file_get_contents('php://input')); // date data in postback field
}
if ($event instanceof \LINE\LINEBot\Event\MessageEvent) {
if ($event instanceof \LINE\LINEBot\Event\MessageEvent\TextMessage) {
$json = array(
"replyToken" => $event->getReplyToken(),
"messages" => [
array(
"type" => "template",
"altText" => "this is a confirm template",
"template" => array(
"type" => "confirm",
"text" => "Are you sure?",
"actions" => [
array(
"type" => "datetimepicker",
"data" => "datestring", // will be included in postback action
"label" => "Please Choose",
"mode" => "date", // date | time | datetime
//"initial": "", // 2017-06-18 | 00:00 | 2017-06-18T00:00
//"max": "", // 2017-06-18 | 00:00 | 2017-06-18T00:00
//"min": "", // 2017-06-18 | 00:00 | 2017-06-18T00:00
),
array(
"type" => "message",
"label" => "No",
"text" => "no"
)
]
)
)
]
);
$curl = curl_init() ;
curl_setopt($curl, CURLOPT_URL, "https://api.line.me/v2/bot/message/reply") ;
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . getenv('CHANNEL_ACCESS_TOKEN')));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($json));
curl_exec($curl);
}
continue;
}
}
?>
Reference
이 문제에 관하여(LINE Messaging API의 Datetime picker action을 PHP로 사용), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/stachibana/items/0b53defbdd27c25658fa텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)