-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcallback_data.php
More file actions
60 lines (55 loc) · 1.28 KB
/
callback_data.php
File metadata and controls
60 lines (55 loc) · 1.28 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
<?php
// By OmarReal
// My Channel Set_Web
ob_start();
define('API_KEY','TOKEN');
function bot($method,$datas=[]){
$url = 'https://api.telegram.org/bot'.API_KEY.'/'.$method;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$datas);
$res = curl_exec($ch);
if(curl_error($ch)){
var_dump(curl_error($ch));
}else{
return json_decode($res);
}
}
$update = json_decode(file_get_contents('php://input'));
$message = $update->message;
$chat_id = $message->chat->id;
$text = $message->text;
$chat_id2 = $update->callback_query->message->chat->id;
$message_id = $update->callback_query->message->message_id;
$data = $update->callback_query->data;
if($text == '/start'){
bot('sendMessage',[
'chat_id'=>$chat_id,
'text'=>'OmarReal',
'reply_markup'=>json_encode([
'inline_keyboard'=>[
[['text'=>'ClickMe One','callback_data'=>'c1']]
]
])
]);
}
if($data == 'c1'){
bot('editMessageText',[
'chat_id'=>$chat_id2,
'message_id=>$message_id,
'text'=>'click done',
'reply_markup'=>json_encode([
'inline_keyboard'=>[
[['text'=>'ClickMe Two','callback_data'=>'c2']]
]
])
]);
}
if($data == 'c2'){
bot('editMessageText',[
'chat_id'=>$chat_id2,
'message_id=>$message_id,
'text'=>'click done two'
]);
}