Liệt kê tài khoản CSS
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ãy sử dụng mẫu này để liệt kê các Tài khoản CSS.
cURL
curl --location 'https://css.googleapis.com/v1/accounts/1234567:listChildAccounts' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API_TOKEN>'
Java
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shopping.css.samples.v1.accounts;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.css.v1.Account;
import com.google.shopping.css.v1.AccountsServiceClient;
import com.google.shopping.css.v1.AccountsServiceClient.ListChildAccountsPagedResponse;
import com.google.shopping.css.v1.AccountsServiceSettings;
import com.google.shopping.css.v1.ListChildAccountsRequest;
import shopping.css.samples.utils.Authenticator;
import shopping.css.samples.utils.Config;
/**
* This class demonstrates how to list the child (CSS domain) Accounts of a given CSS group Account
*/
public class ListCssAccounts {
private static String getParent(String accountId) {
return String.format("accounts/%s", accountId);
}
public static void listCssAccounts(Config config) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
AccountsServiceSettings accountsServiceSettings =
AccountsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String parent = getParent(config.getGroupId().toString());
try (AccountsServiceClient accountsServiceClient =
AccountsServiceClient.create(accountsServiceSettings)) {
ListChildAccountsRequest request =
ListChildAccountsRequest.newBuilder().setParent(parent).build();
System.out.println("Sending ListChildAccounts request");
ListChildAccountsPagedResponse response = accountsServiceClient.listChildAccounts(request);
System.out.println("Retrieved Accounts: ");
int count = 0;
// Iterates over all rows in all pages and prints the element in each row
for (Account element : response.iterateAll()) {
System.out.println(element);
count++;
}
System.out.print("The following count of elements were returned: ");
System.out.println(count);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
final Config config = Config.load();
listCssAccounts(config);
}
}
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-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eThis sample code demonstrates how to retrieve and list child accounts associated with a given CSS group account.\u003c/p\u003e\n"],["\u003cp\u003eIt utilizes the Content API for Shopping and provides examples in both cURL and Java.\u003c/p\u003e\n"],["\u003cp\u003eThe Java example includes comprehensive code showcasing authentication, request construction, and response handling for listing child CSS accounts.\u003c/p\u003e\n"]]],[],null,["# List CSS Accounts\n\nUse this sample to list CSS Accounts. \n\n### cURL\n\n curl --location 'https://css.googleapis.com/v1/accounts/1234567:listChildAccounts' \\\n --header 'Content-Type: application/json' \\\n --header 'Authorization: Bearer \u003cAPI_TOKEN\u003e'\n\n### Java\n\n // Copyright 2023 Google LLC\n //\n // Licensed under the Apache License, Version 2.0 (the \"License\");\n // you may not use this file except in compliance with the License.\n // You may obtain a copy of the License at\n //\n // https://www.apache.org/licenses/LICENSE-2.0\n //\n // Unless required by applicable law or agreed to in writing, software\n // distributed under the License is distributed on an \"AS IS\" BASIS,\n // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n // See the License for the specific language governing permissions and\n // limitations under the License.\n\n package shopping.css.samples.v1.accounts;\n\n import com.google.api.gax.core.FixedCredentialsProvider;\n import com.google.auth.oauth2.GoogleCredentials;\n import com.google.shopping.css.v1.Account;\n import com.google.shopping.css.v1.AccountsServiceClient;\n import com.google.shopping.css.v1.AccountsServiceClient.ListChildAccountsPagedResponse;\n import com.google.shopping.css.v1.AccountsServiceSettings;\n import com.google.shopping.css.v1.ListChildAccountsRequest;\n import shopping.css.samples.utils.Authenticator;\n import shopping.css.samples.utils.Config;\n\n /**\n * This class demonstrates how to list the child (CSS domain) Accounts of a given CSS group Account\n */\n public class ListCssAccounts {\n\n private static String getParent(String accountId) {\n return String.format(\"accounts/%s\", accountId);\n }\n\n public static void listCssAccounts(Config config) throws Exception {\n GoogleCredentials credential = new Authenticator().authenticate();\n\n AccountsServiceSettings accountsServiceSettings =\n AccountsServiceSettings.newBuilder()\n .setCredentialsProvider(FixedCredentialsProvider.create(credential))\n .build();\n\n String parent = getParent(config.getGroupId().toString());\n\n try (AccountsServiceClient accountsServiceClient =\n AccountsServiceClient.create(accountsServiceSettings)) {\n\n ListChildAccountsRequest request =\n ListChildAccountsRequest.newBuilder().setParent(parent).build();\n\n System.out.println(\"Sending ListChildAccounts request\");\n ListChildAccountsPagedResponse response = accountsServiceClient.listChildAccounts(request);\n System.out.println(\"Retrieved Accounts: \");\n\n int count = 0;\n\n // Iterates over all rows in all pages and prints the element in each row\n for (Account element : response.iterateAll()) {\n System.out.println(element);\n count++;\n }\n System.out.print(\"The following count of elements were returned: \");\n System.out.println(count);\n } catch (Exception e) {\n System.out.println(e);\n }\n }\n\n public static void main(String[] args) throws Exception {\n final Config config = Config.load();\n\n listCssAccounts(config);\n }\n } \n https://github.com/googleads/comparison-shopping-service-api-samples/blob/2f511c3ca413bdbd497f89ae7468b3191dafaa6d/java/src/main/java/shopping/css/samples/v1/accounts/ListCssAccounts.java"]]