-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexamples.php
121 lines (117 loc) · 2.88 KB
/
examples.php
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
include("Messenger.php");
$apiKey = "YOUR_API_KEY";
// Instances the Facebook class
$facebook = new Messenger($apiKey);
// Take text and chat_id from the message
$text = $facebook->Text();
$chat_id = $facebook->ChatID();
$message_id = $facebook->EntryID();
$message = "";
$result = "";
if(!is_null($text) && !is_null($chat_id))
{
if ($text == "text") // simple text message
{
$message = "Hello World";
$result = $facebook->sendMessage($chat_id, $message);
}
else if ($text == "button") // buttons
{
$message = "Hello World";
$button = array(
array(
'type' => 'web_url',
'url' => 'https://google.com',
'title' => 'Button 1'
),
array(
'type' => 'web_url',
'url' => 'https://google.com',
'title' => 'Button 2'
),
array(
'type' => 'web_url',
'url' => 'https://google.com',
'title' => 'Button 3'
)
);
$result = $facebook->sendButtonTemplate($chat_id, $message, $button);
}
else if ($text == "replies") // quick replies
{
$message = "Pick one";
$replies = array(
array(
'content_type' => 'text',
'title' => 'Option One',
'payload' => 'PAYLOAD_ONE'
),
array(
'content_type' => 'text',
'title' => 'Option Two',
'payload' => 'PAYLOAD_TWO'
),
array(
'content_type' => 'text',
'title' => 'Option Three',
'payload' => 'PAYLOAD_THREE'
)
);
$result = $facebook->sendQuickReply($chat_id, $message, $replies);
}
else if ($text == "generic") // generic template
{
$button = array(
array(
'type' => 'web_url',
'url' => 'https://google.com',
'title' => 'Button One'
),
array(
'type' => 'web_url',
'url' => 'https://google.com',
'title' => 'Button Two'
)
);
$elements = array(
array(
'title' => 'Title One',
'item_url' => 'https://google.com',
'image_url' => 'http://placehold.it/350x350',
'subtitle' => 'Item Description Here',
'buttons' => $button
),
array(
'title' => 'Title Two',
'item_url' => 'https://google.com',
'image_url' => 'http://placehold.it/350x350',
'subtitle' => 'Item Description Here',
'buttons' => $button
),
array(
'title' => 'Title Three',
'item_url' => 'https://google.com',
'image_url' => 'http://placehold.it/350x350',
'subtitle' => 'Item Description Here',
'buttons' => $button
),
array(
'title' => 'Title Four',
'item_url' => 'https://google.com',
'image_url' => 'http://placehold.it/350x350',
'subtitle' => 'Item Description Here',
'buttons' => $button
),
array(
'title' => 'Title Five',
'item_url' => 'https://google.com',
'image_url' => 'http://placehold.it/350x350',
'subtitle' => 'Item Description Here',
'buttons' => $button
)
);
$result = $facebook->sendGenericTemplate($chat_id, $elements);
}
}
?>