-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
81 lines (73 loc) · 2.4 KB
/
index.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
$channelAccessToken = '1caj07yURrrjtw3H9hzJ+bWYo+rsam3iGzbrYrrRhjH7zZqHuz3Dujm0jtJsVTThFpev/g0oK8CZYAON18xdMenFO+a02ALh4r2OlXPFyPsBscfr7b4IZwNoBOVLfS6RUA70p2pIWk3dpq+U8aHwtQdB04t89/1O/w1cDnyilFU='; //Your Channel Access Token
$channelSecret = '5e8d1f791608a58b43c5bd31c986d955';//Your Channel Secret
$client = new LINEBotTiny($channelAccessToken, $channelSecret);
$userId = $client->parseEvents()[0]['source']['userId'];
$replyToken = $client->parseEvents()[0]['replyToken'];
$message = $client->parseEvents()[0]['message'];
$profil = $client->profil($userId);
$pesan_datang = $message['text'];
if($message['type']=='sticker')
{
$balas = array(
'UserID' => $profil->userId,
'replyToken' => $replyToken,
'messages' => array(
array(
'type' => 'text',
'text' => 'Terima Kasih Stikernya.'
)
)
);
}
else
$pesan=str_replace(" ", "%20", $pesan_datang);
$key = 'YOUR-API-KEY-SIMSIMI'; //API SimSimi
$url = 'http://sandbox.api.simsimi.com/request.p?key='.$key.'&lc=id&ft=1.0&text='.$pesan;
$json_data = file_get_contents($url);
$url=json_decode($json_data,1);
$diterima = $url['response'];
if($message['type']=='text')
{
if($url['result'] == 404)
{
$balas = array(
'UserID' => $profil->userId,
'replyToken' => $replyToken,
'messages' => array(
array(
'type' => 'text',
'text' => 'Mohon Gunakan Bahasa Indonesia Yang Benar :D.'
)
)
);
}
else
if($url['result'] != 100)
{
$balas = array(
'UserID' => $profil->userId,
'replyToken' => $replyToken,
'messages' => array(
array(
'type' => 'text',
'text' => 'Maaf '.$profil->displayName.' Server Kami Sedang Sibuk Sekarang.'
)
)
);
}
else{
$balas = array(
'UserID' => $profil->userId,
'replyToken' => $replyToken,
'messages' => array(
array(
'type' => 'text',
'text' => ''.$diterima.''
)
)
);
}
}
$result = json_encode($balas);
file_put_contents('./reply.json',$result);
$client->replyMessage($balas);