daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $updates = file_get_contents("https://api.telegram.org/bot369168536:AAFVXpJ3TQEam6Bz3khNfz2kRxJWkoBnw-A/getUpdates");
  3. $updates = json_decode($updates, true);
  4. $messages = $updates["result"][0]["message"]["text"];
  5. $usermessage = htmlspecialchars($_POST["message"]);
  6. function sendMessage($chatid, $message, $token)
  7. {
  8.    $url = "https://api.telegram.org/bot{$token}/sendMessage?" . http_build_query([
  9.    'chat_id' => $chatid,
  10.    'text' => $message
  11. ]);
  12.    $ch = curl_init();
  13.    $optArray = [
  14.        CURLOPT_URL => $url,
  15.        CURLOPT_RETURNTRANSFER => true
  16.    ];
  17.    curl_setopt_array($ch, $optArray);
  18.    curl_exec($ch);
  19.    curl_close($ch);
  20.  }
  21.  
  22.    $host        = "host = 127.0.0.1";
  23.    $port        = "port = 5432";
  24.    $dbname      = "dbname = postgres";
  25.    $credentials = "user = postgres password=13371488";
  26.  
  27.    $db = pg_connect( "$host $port $dbname $credentials"  );
  28.    if(!$db) {
  29.       echo "Error : Unable to open database\n";
  30.    } else {
  31.       echo "Opened database successfully\n";
  32.    }
  33. $sql =<<<EOF
  34.       SELECT chat_id from USERS;
  35. EOF;
  36.  
  37.    $ret = pg_query($db, $sql);
  38.    if(!$ret) {
  39.       echo pg_last_error($db);
  40.       exit;
  41.    }
  42.    while($row = pg_fetch_row($ret)) {
  43.    sendMessage($row[0], , "369168536:AAFVXpJ3TQEam6Bz3khNfz2kRxJWkoBnw-A");
  44. }
  45.   pg_close($db);
  46. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top