fuc/public/tests/hook.php
2025-04-01 20:18:38 +08:00

101 lines
1.6 KiB
PHP

<?php
include("include/head.php");
include("../../src/Services/TomTool/Http.php");
include("../../config/.config.php");
//use App\Services\TomTool\Http;
$oHttp = new App\Services\TomTool\Http();
$oHttp->sMethod = "post";
$oHttp->sToUrl = $_ENV['baseUrl']."/api/tg/hook";
//$oHttp->sToUrl = 'https://fuc.loc/test3';
$oHttp->bIsJson = true;
//$oHttp->aData[]
$oHttp->aData = [
'update_id' => 123456789,
'message' => [
'message_id' => 1,
'from' => [
'id' => 7740568271,
'is_bot' => false,
'first_name' => 'John',
'last_name' => 'Doe',
'username' => 'johndoe',
'language_code' => 'en'
],
'chat' => [
'id' => -4668400285,
'first_name' => 'John',
'last_name' => 'Doe',
'username' => 'johndoe',
'type' => 'private'
],
'date' => 1610000000,
'text' => '/reportUser_day_3'
]
];
$r = $oHttp->send();
var_dump($r);
exit;
$url = 'https://fuc.loc/api/tg/hook';
$url = 'https://fuc.loc/test3';
$data = [
'message' => [
'chat' => [
'id' => '-4668400285'
],
'text' => '/reply 11 sss'
]
];
$options = [
'http' => [
'header' => "Content-Type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($data),
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
die('Error');
}
echo $result;
exit;
?>