-
Notifications
You must be signed in to change notification settings - Fork 1
/
data.php
49 lines (44 loc) · 1.71 KB
/
data.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
<?php
$con = mysqli_connect("localhost","","","");
$channelAccessToken = '';
$channelSecret = '';
$client = new LINEBotTiny($channelAccessToken, $channelSecret);
// Data Data Pengguna, Group, Room
$userId = $client->parseEvents()[0]['source']['userId'];
$groupId = $client->parseEvents()[0]['source']['groupId'];
$roomId = $client->parseEvents()[0]['source']['roomId'];
$replyToken = $client->parseEvents()[0]['replyToken'];
$timestamp = $client->parseEvents()[0]['timestamp'];
$type = $client->parseEvents()[0]['type'];
$message = $client->parseEvents()[0]['message'];
$messageid = $client->parseEvents()[0]['message']['id'];
$profil = $client->profil($userId);
$profileName = $profil->displayName;
$profileURL = $profil->pictureUrl;
$profielStatus = $profil->statusMessage;
// Jenis Pesan Postback
$datetime = $client->parseEvents()[0]['postback']['params']['date'];
$postbackData = $client->parseEvents()[0]['postback']['data'];
$postbackPesan = explode(" ", strtolower($postbackData));
$postbackPesans = explode(" ", $postbackData);
$commandPostbacks = $postbackPesans[0];
$optionsPostbacks = $postbackPesans[1];
$commandPostback = $postbackPesan[0];
$optionsPostback = $postbackPesan[1];
if (count($postbackPesan) > 2) {
for ($i = 2; $i < count($postbackPesan); $i++) {
$optionsPostback .= '+';
$optionsPostback .= $postbackPesan[$i];
}
}
// Jenis Pesan Teks
$commandSingle = strtolower($message['text']);
$pesan_datang = explode(" ", $commandSingle);
$command = $pesan_datang[0];
$options = $pesan_datang[1];
if (count($pesan_datang) > 2) {
for ($i = 2; $i < count($pesan_datang); $i++) {
$options .= '+';
$options .= $pesan_datang[$i];
}
}