-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.php
96 lines (81 loc) · 2.55 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/*
copyright @ medantechno.com
Modified by Ilyasa
And Modified Again by Farzain - zFz
2017
*/
require_once('./line_class.php');
$channelAccessToken = 'MTn2latTZ4NmBnuah67007iRDPdliDVKkpxR1yb5IGpzTARdjzAqSnLmhkvew0EqfNs3wDSQuTc8j/DUfKCoPFpV3ECtur1KUxyiRd1jZjeS9JA7yJXlkuK6l6/WkCJEKDybBDiRMdFbYxtFlRYOmQdB04t89/1O/w1cDnyilFU='; //Your Channel Access Token
$channelSecret = 'adbb3952c8bc75b90664aa5ededbbbec';//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 = '9f256a21-5d2f-4ae2-874a-e500a50bb04c'; //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);