Sổ địa chỉ qua người dùng API

Để sổ địa chỉ người dùng qua API trên API.socdo.vn, bạn cần gửi user_id 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
POST https://api.socdo.vn/v1/address_book
các trường cần truyền lên:
  • user_id: ID tài khoản (bạn có thể tìm thấy nó khi bạn đăng nhập tài khoản qua API)
Dữ liệu truyền lên (JSON):
{
    "user_id": "your_user_id"
}
Ví dụ kết nối bằng cURL:
curl -X POST "https://api.socdo.vn/v1/address_book" -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"user_id": "your_user_id"}'
Ví dụ kết nối bằng PHP:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.socdo.vn/v1/address_book");
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([
    "user_id" => "your_user_id"
]));
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
Dữ liệu trả về mẫu:
{
    "success": true,
    "data": [
        {
            "user_id": 8395,
            "ho_ten": "Trần Văn Hoàn",
            "dien_thoai": "0829525943",
            "dia_chi": "HD",
            "email": "[email protected]",
            "ten_tinh": "Tỉnh Hải Dương",
            "ten_huyen": "Huyện Cẩm Giàng",
            "ten_xa": "Xã Cẩm Hưng",
            "active": 1
        },
        {
            "user_id": 8395,
            "ho_ten": "Trần Văn Hoàn",
            "dien_thoai": "0888888888",
            "dia_chi": "100",
            "email": "[email protected]",
            "ten_tinh": "Tỉnh ABC",
            "ten_huyen": "Huyện XYZ",
            "ten_xa": "Xã 123",
            "active": 0
        }
    ]
}
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 user_id bạn có thể tìm thấy nó khi bạn đăng nhập tài khoản qua API
Để 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.