Làm việc với dữ liệu tài khoản
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Hướng dẫn này cho bạn biết cách xử lý dữ liệu tài khoản. My Business Account Management API cho phép bạn thực hiện những việc sau:
- Liệt kê tất cả tài khoản.
- Trả về một tài khoản cụ thể.
- Cập nhật tài khoản.
Trước khi bắt đầu
Trước khi sử dụng API Quản lý tài khoản Doanh nghiệp của tôi, bạn cần đăng ký ứng dụng và lấy thông tin xác thực OAuth 2.0.
Để biết thông tin chi tiết về cách bắt đầu sử dụng API Trang doanh nghiệp, hãy xem phần Thiết lập cơ bản.
Liệt kê tất cả tài khoản
Một cách hay để xác thực các tài khoản được liên kết với một người dùng đã xác thực là liệt kê tất cả tài khoản của họ. Sử dụng API accounts.list
để liệt kê tất cả tài khoản được liên kết với một người dùng.
Để liệt kê tất cả tài khoản của một người dùng đã được xác thực, hãy sử dụng mã sau:
$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts
Trả về một tài khoản cụ thể
Đôi khi, bạn chỉ muốn xem thông tin về một tài khoản cụ thể của một người dùng đã được xác thực. Sử dụng API accounts.get
để trả về một tài khoản cụ thể và xem lại các thông tin bổ sung về tài khoản.
Để trả về một tài khoản cụ thể theo tên, hãy sử dụng mã sau:
$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}
Cập nhật tài khoản
Thay đổi tên tài khoản là một nhiệm vụ quản trị cơ bản. Sử dụng API accounts.update
để thay đổi tên tài khoản.
Để cập nhật một tài khoản cụ thể theo tên, hãy sử dụng mã sau:
$ PUT https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}
{
"account": {
"accountName": "Anne Droyd"
},
"languageCode": "en",
"validateOnly": "true"
}
Quy định hạn chế
- Trường duy nhất có thể chỉnh sửa cho một tài khoản là
accountName
. Mọi trường khác được truyền sẽ bị bỏ qua.
- Bạn chỉ có thể cập nhật tài khoản thuộc loại
BUSINESS
theo cách này.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-29 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[[["\u003cp\u003eThe My Business Account Management API allows you to manage business accounts, including listing all accounts, retrieving specific account details, and updating account names.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, you must register your application and obtain OAuth 2.0 credentials as outlined in the basic setup guide.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve a list of all accounts associated with an authenticated user or fetch details for a specific account using dedicated API endpoints.\u003c/p\u003e\n"],["\u003cp\u003eUpdating an account is restricted to changing the account name for business type accounts only, with other fields being ignored.\u003c/p\u003e\n"]]],[],null,["# Work with account data\n\n\u003cbr /\u003e\n\nThis tutorial shows you how to work with account data. The My Business Account Management API\nprovides you with the ability to do the following:\n\n- List all accounts.\n- Return a specific account.\n- Update an account.\n\nBefore you begin\n----------------\n\nBefore you use the My Business Account Management API, you need to register your application\nand obtain OAuth 2.0 credentials.\n\nFor details on how to get started with the Business Profile APIs, see\n[Basic setup](/my-business/content/basic-setup).\n\nList all accounts\n-----------------\n\nA great way to validate the accounts associated with an authenticated user is to\nlist all their accounts. Use the [`accounts.list`](/my-business/reference/accountmanagement/rest/v1/accounts/list)\nAPI to list all accounts associated with a user.\n\nTo list all the accounts for an authenticated user, use the following:\nHTTP \n\n```bash\n$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts\n```\n\nReturn a specific account\n-------------------------\n\nSometimes, you only want to see information about a specific account for an\nauthenticated user. Use the [`accounts.get`](/my-business/reference/accountmanagement/rest/v1/accounts/get)\nAPI to return a specific account and review additional account details.\n\nTo return a specific account by name, use the following:\nHTTP \n\n```bash\n$ GET https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}\n```\n\nUpdate an account\n-----------------\n\nChanging an account name is a fundamental administrative task. Use the\n[`accounts.update`](/my-business/reference/accountmanagement/rest/v1/accounts/patch) API to alter\nthe account name.\n\nTo update a specific account by name, use the following:\nHTTP \n\n```bash\n$ PUT https://mybusinessaccountmanagement.googleapis.com/v1/accounts/{accountId}\n\n{\n \"account\": {\n \"accountName\": \"Anne Droyd\"\n },\n \"languageCode\": \"en\",\n \"validateOnly\": \"true\"\n}\n```\n\n### Restrictions\n\n- The only editable field for an account is `accountName`. Any other fields passed are ignored.\n- Only accounts of `BUSINESS` type can be updated in this manner."]]