আপনি CustomerService
এ ListAccessibleCustomers
পদ্ধতি ব্যবহার করে আপনার কাছে অ্যাক্সেসযোগ্য গ্রাহকদের তালিকাভুক্ত করতে পারেন। তবে, এই ধরণের অনুরোধে কোন গ্রাহকদের ফেরত পাঠানো হয় তা বোঝা প্রয়োজন।
অ্যাক্সেসযোগ্য গ্রাহকদের তালিকা তৈরি করা হল Google Ads API-এর কয়েকটি অনুরোধের মধ্যে একটি যার জন্য অনুরোধে গ্রাহক আইডি নির্দিষ্ট করার প্রয়োজন হয় না এবং অনুরোধটি সরবরাহ করা যেকোনো login-customer-id
উপেক্ষা করে। গ্রাহকদের তালিকা আপনার OAuth শংসাপত্রের উপর ভিত্তি করে তৈরি করা হয়। অনুরোধটি আপনার বর্তমান শংসাপত্রের ভিত্তিতে সরাসরি কাজ করতে সক্ষম এমন সমস্ত অ্যাকাউন্টের একটি তালিকা ফেরত দেয়। এতে অ্যাকাউন্টের শ্রেণিবিন্যাসের মধ্যে থাকা সমস্ত অ্যাকাউন্ট অন্তর্ভুক্ত থাকবে না; বরং, এটি কেবলমাত্র সেই অ্যাকাউন্টগুলি অন্তর্ভুক্ত করবে যেখানে আপনার অনুমোদিত ব্যবহারকারীকে অ্যাডমিন বা অ্যাকাউন্টে অন্যান্য অধিকার সহ যোগ করা হয়েছে।
কল্পনা করুন যে আপনি একজন ব্যবহারকারী A
যিনি চিত্রে দেখানো দুটি শ্রেণিবিন্যাসে M1
এবং C3
এর একজন প্রশাসক। আপনি যদি Google Ads API তে কল করেন, উদাহরণস্বরূপ GoogleAdsService
তে, তাহলে আপনি M1
, C1
, C2
, এবং C3
অ্যাকাউন্টের তথ্য অ্যাক্সেস করতে পারবেন। তবে, CustomerService.ListAccessibleCustomers
এ কল করলে শুধুমাত্র M1
এবং C3
ফিরে আসবে কারণ এই দুটি অ্যাকাউন্টেই ব্যবহারকারী A
সরাসরি অ্যাক্সেস রয়েছে।
CustomerService.ListAccessibleCustomers
পদ্ধতির ব্যবহার ব্যাখ্যা করার জন্য এখানে একটি কোড উদাহরণ দেওয়া হল:
জাভা
private void runExample(GoogleAdsClient client) { // Optional: Change credentials to use a different refresh token, to retrieve customers // available for a specific user. // // UserCredentials credentials = // UserCredentials.newBuilder() // .setClientId("INSERT_OAUTH_CLIENT_ID") // .setClientSecret("INSERT_OAUTH_CLIENT_SECRET") // .setRefreshToken("INSERT_REFRESH_TOKEN") // .build(); // // client = client.toBuilder().setCredentials(credentials).build(); try (CustomerServiceClient customerService = client.getLatestVersion().createCustomerServiceClient()) { ListAccessibleCustomersResponse response = customerService.listAccessibleCustomers( ListAccessibleCustomersRequest.newBuilder().build()); System.out.printf("Total results: %d%n", response.getResourceNamesCount()); for (String customerResourceName : response.getResourceNamesList()) { System.out.printf("Customer resource name: %s%n", customerResourceName); } } }
সি#
public void Run(GoogleAdsClient client) { // Get the CustomerService. CustomerServiceClient customerService = client.GetService(Services.V22.CustomerService); try { // Retrieve the list of customer resources. string[] customerResourceNames = customerService.ListAccessibleCustomers(); // Display the result. foreach (string customerResourceName in customerResourceNames) { Console.WriteLine( $"Found customer with resource name = '{customerResourceName}'."); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
পিএইচপি
public static function runExample(GoogleAdsClient $googleAdsClient) { $customerServiceClient = $googleAdsClient->getCustomerServiceClient(); // Issues a request for listing all accessible customers. $accessibleCustomers = $customerServiceClient->listAccessibleCustomers(new ListAccessibleCustomersRequest()); print 'Total results: ' . count($accessibleCustomers->getResourceNames()) . PHP_EOL; // Iterates over all accessible customers' resource names and prints them. foreach ($accessibleCustomers->getResourceNames() as $resourceName) { /** @var string $resourceName */ printf("Customer resource name: '%s'%s", $resourceName, PHP_EOL); } }
পাইথন
def main(client: GoogleAdsClient) -> None: customer_service: CustomerServiceClient = client.get_service( "CustomerService" ) accessible_customers: ListAccessibleCustomersResponse = ( customer_service.list_accessible_customers() ) result_total: int = len(accessible_customers.resource_names) print(f"Total results: {result_total}") resource_names: List[str] = accessible_customers.resource_names for resource_name in resource_names: # resource_name is implicitly str print(f'Customer resource name: "{resource_name}"')
রুবি
def list_accessible_customers() # GoogleAdsClient will read a config file from # ENV['HOME']/google_ads_config.rb when called without parameters client = Google::Ads::GoogleAds::GoogleAdsClient.new accessible_customers = client.service.customer.list_accessible_customers().resource_names accessible_customers.each do |resource_name| puts "Customer resource name: #{resource_name}" end end
পার্ল
sub list_accessible_customers { my ($api_client) = @_; my $list_accessible_customers_response = $api_client->CustomerService()->list_accessible_customers(); printf "Total results: %d.\n", scalar @{$list_accessible_customers_response->{resourceNames}}; foreach my $resource_name (@{$list_accessible_customers_response->{resourceNames}}) { printf "Customer resource name: '%s'.\n", $resource_name; } return 1; }
কার্ল করা
# Returns the resource names of customers directly accessible by the user # authenticating the call. # # Variables: # API_VERSION, # DEVELOPER_TOKEN, # OAUTH2_ACCESS_TOKEN: # See https://developers.google.com/google-ads/api/rest/auth#request_headers # for details. # curl -f --request GET \ "https://googleads.googleapis.com/v${API_VERSION}/customers:listAccessibleCustomers" \ --header "Content-Type: application/json" \ --header "developer-token: ${DEVELOPER_TOKEN}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
বাতিল করা অ্যাকাউন্টগুলির তালিকা তৈরি করুন
Google Ads API বাতিল করা অ্যাকাউন্টগুলিকে ম্যানেজার অ্যাকাউন্টের অধীনে তালিকাভুক্ত করার সরাসরি কোনও উপায় প্রদান করে না। তবে, এই তালিকাটি পুনরুদ্ধার করতে আপনি নিম্নলিখিত সমাধানগুলি ব্যবহার করতে পারেন।
customer_client_link
রিসোর্স ব্যবহার করেACTIVE
লিঙ্কের তালিকাটি পুনরুদ্ধার করুন এবংcustomer_client_link.client_customer
ফিল্ড ব্যবহার করে গ্রাহকদের একটি তালিকা তৈরি করুন।SELECT customer_client_link.client_customer, customer_client_link.status FROM customer_client_link WHERE customer_client_link.status = ACTIVE
customer_client
রিসোর্স ব্যবহার করেENABLED
অ্যাকাউন্টগুলির তালিকা পুনরুদ্ধার করুন।SELECT customer_client.id, customer_client.descriptive_name FROM customer_client
দুটি তালিকার মধ্যে পার্থক্য আপনাকে বাতিল অ্যাকাউন্টগুলির তালিকা দেয়।