Đăng nhập tài khoản qua API
Để đăng nhập tài khoản trên API.socdo.vn, bạn cần gửi username (hoặc email/số điện thoại) và password kèm theo token xác thực (JWT) vào endpoint dưới đây.
Ví dụ minh họa: Đăng nhập tài khoản
Ví dụ minh họa: Đăng nhập tài khoản
POST https://api.socdo.vn/v1/login
Các trường cần truyền lên:
- username: Tên đăng nhập, email hoặc số điện thoại
- password: Mật khẩu tài khoản
- token: Token xác thực (JWT), truyền qua header
Authorization: Bearer <token>
Dữ liệu truyền lên (JSON):
{
"username": "your_username",
"password": "your_password"
}
Ví dụ kết nối bằng cURL:
curl -X POST "https://api.socdo.vn/v1/login" -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"username": "your_username", "password": "your_password"}'
Ví dụ kết nối bằng PHP:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.socdo.vn/v1/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer <token>"
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"username" => "your_username",
"password" => "your_password"
]));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
Dữ liệu trả về mẫu:
{
"success": true,
"message": "Đăng nhập thành công",
"data": {
"user_id": "your user_id",
"username": "your_username",
"email": "[email protected]",
"name": "Tên người dùng",
"mobile": "0987654321"
}
}
Lưu ý: Bạn cần lấy token xác thực trước khi gọi API này (xem hướng dẫn lấy token ở mục Get token xác thực).
Trường username có thể là tên đăng nhập, email hoặc số điện thoại đã đăng ký.
Để xem hướng dẫn chi tiết từng API, vui lòng chọn chức năng ở menu bên trái.
Trường username có thể là tên đăng nhập, email hoặc số điện thoại đã đăng ký.
Để xem hướng dẫn chi tiết từng API, vui lòng chọn chức năng ở menu bên trái.