Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $updates = file_get_contents("https://api.telegram.org/bot369168536:AAFVXpJ3TQEam6Bz3khNfz2kRxJWkoBnw-A/getUpdates");
- $updates = json_decode($updates, true);
- $messages = $updates["result"][0]["message"]["text"];
- $usermessage = htmlspecialchars($_POST["message"]);
- function sendMessage($chatid, $message, $token)
- {
- $url = "https://api.telegram.org/bot{$token}/sendMessage?" . http_build_query([
- 'chat_id' => $chatid,
- 'text' => $message
- ]);
- $ch = curl_init();
- $optArray = [
- CURLOPT_URL => $url,
- CURLOPT_RETURNTRANSFER => true
- ];
- curl_setopt_array($ch, $optArray);
- curl_exec($ch);
- curl_close($ch);
- }
- $host = "host = 127.0.0.1";
- $port = "port = 5432";
- $dbname = "dbname = postgres";
- $credentials = "user = postgres password=13371488";
- $db = pg_connect( "$host $port $dbname $credentials" );
- if(!$db) {
- echo "Error : Unable to open database\n";
- } else {
- echo "Opened database successfully\n";
- }
- $sql =<<<EOF
- SELECT chat_id from USERS;
- EOF;
- $ret = pg_query($db, $sql);
- if(!$ret) {
- echo pg_last_error($db);
- exit;
- }
- while($row = pg_fetch_row($ret)) {
- sendMessage($row[0], , "369168536:AAFVXpJ3TQEam6Bz3khNfz2kRxJWkoBnw-A");
- }
- pg_close($db);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement