cfn/app/Services/TG/Http.php
2025-06-17 16:25:35 +08:00

61 lines
1.3 KiB
PHP

<?php
namespace App\Services\TG;
class Http {
public $sApiToken;
public $sApiChatId;
function __construct()
{
$this->sApiToken = env('telegram_token');
$this->sApiChatId = env('telegram_chatid');
}
public function sendToTG($sMsg, $mType = false)
{
if ($mType == "dove") {
if (env("is_loc") == true) {
echo "<pre>";
}
echo $sMsg;
} else {
if (env("is_loc") == true) {
echo "<pre>";
echo($sMsg);
} else {
$url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
file_get_contents($url);
}
}
// if ($mType == "dove") {
//
// echo $sMsg;
//
// } else if (env('is_loc') == true) {
//
// echo "<pre>";
// echo($sMsg);
//
// } else {
//
// $url = "https://api.telegram.org/bot$this->sApiToken/sendMessage?chat_id=$this->sApiChatId&text=" . urlencode($sMsg);
// file_get_contents($url);
//
// }
}
}