-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebhook.php
More file actions
147 lines (61 loc) · 2.22 KB
/
webhook.php
File metadata and controls
147 lines (61 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if($verify_token === 'asdf'){ echo $challenge; }
$input = json_decode(file_get_contents('php://input'), true); // Get the Senders Graph ID
$sender = $input['entry'][0]['messaging'][0]['sender']['id']; // App Id
$message = $input['entry'][0]['messaging'][0]['message']['text']; // App Message
$url = "https://graph.facebook.com/v2.6/me/messages?access_token=EAAf3RB3BKl4BAPV6XB8tRGnqRkNZByRSB3eBctwbncXHfw4G77MCoZCJP6RDTLmS8ZBGcF1TAQZBS43CQGUJlYqj8e1ZBNlCqmIkXXJ6UvP7vu18MoP9aAfpVLQ3kkgDf0rb9LucbPmlK3fkfMRAQMc4VrgGOUu3PKgLjpdOZC4AZDZD";
$ch = curl_init($url);
include "function/main.php";
// 응답 메뉴
$jsonData = '{
"recipient":{
"id":"' . $sender . '"
},
"message":{
"text":"' . $message . '"
}
}';
//메시지 이후 버튼
$jsonData = '{
"recipient":{
"id":"' . $sender . '"
},
"message":{
"text": "잘못된 입력입니다\n아래에 있는 버튼을 눌러 선택해주세요",
"quick_replies":[
{
"content_type":"text",
"title":"급식",
"payload":"<DEVELOPER_DEFINED_PAYLOAD>"
},
{
"content_type":"text",
"title":"알림장",
"payload":"<DEVELOPER_DEFINED_PAYLOAD>"
},
{
"content_type":"text",
"title":"시간표",
"payload":"<DEVELOPER_DEFINED_PAYLOAD>"
},
{
"content_type":"text",
"title":"날씨",
"payload":"<DEVELOPER_DEFINED_PAYLOAD>"
},
{
"content_type":"text",
"title":"설정",
"payload":"<DEVELOPER_DEFINED_PAYLOAD>"
}
]
}
}';
$jsonData = facebook_reply($sender , $message);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
if(!empty($input['entry'][0]['messaging'][0]['message'])){ $result = curl_exec($ch); }
?>