<?php
function loginTeamobi($username, $password) {
$url = 'https://my.teamobi.com/app/index.php?do=login';
// Dữ liệu POST
$postData = http_build_query([
'user' => $username,
'pass' => $password,
'back' => 'http://my.teamobi.com/threads/1000010599/Top-diem-danh-Hang-dong-Tekkan-Tu-20-4-den-4-5Co-dIeU-CHiNH--0.html'
]);
// Khởi tạo cURL
$ch = curl_init();
// Thiết lập các tùy chọn cho cURL
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
// Thêm các header
$headers = [
'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'accept-language: en-US,en;q=0.9',
'cache-control: no-cache',
'content-type: application/x-www-form-urlencoded',
'origin: https://my.teamobi.com',
'referer: https://my.teamobi.com/login.html',
'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0'
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Thực hiện yêu cầu cURL
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Đóng cURL
curl_close($ch);
// Kiểm tra mã trạng thái HTTP
if ($httpCode == 302) {
return "Login successful! HTTP Code: 302";
} elseif ($httpCode == 200) {
return "Login failed. HTTP Code: 200";
} else {
return "Unexpected HTTP Code: $httpCode";
}
}
// Thử nghiệm
$username = 'taikhoan';
$password = 'matkhau';
echo loginTeamobi($username, $password);