-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.php
More file actions
29 lines (16 loc) · 723 Bytes
/
Copy pathstatic.php
File metadata and controls
29 lines (16 loc) · 723 Bytes
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
<?php
echo "Hello, world" ;
$botToken = "330544559:AAEGpcl9x2qPAfS2tO9gEtmi2yT2AKkeyFQ" ;
$website = "https://api.telegram.org/bot".$botToken ;
$update = file_get_contents("php://input");
$updateArray = json_decode($update, TRUE) ;
$chatId = $updateArray["message"]["chat"]["id"] ;
$text =$updateArray["message"]["text"] ;
$SOsearch = 'https://api.stackexchange.com//2.2/similar?order=desc&sort=relevance&site=math' ;
$search = rawurlencode($text) ;
$urlpost = file_get_contents($SOsearch.'&title='.$search);
$urlpostArray = json_decode($urlpost, TRUE) ;
$topResult = $urlpostArray['items'][0]['link'];
print_r($topResult) ;
file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=$topResult") ;
?>