शुरू करें

Authorized Buyers के साथ प्रोग्राम के ज़रिए इंटरैक्ट करने के लिए, आप तीन एपीआई इस्तेमाल कर सकते हैं:

यहां ऐसे टास्क के कुछ उदाहरण दिए गए हैं जिन्हें Authorized Buyers API का इस्तेमाल करके पूरा किया जा सकता है:

  • रीयल-टाइम बिडिंग से जुड़े खाते की जानकारी ऐक्सेस करें.
  • समीक्षा वाले क्रिएटिव को सबमिट और मैनेज करना.
  • रीयल-टाइम बिडिंग से जुड़ी समस्या हल करने वाली मेट्रिक पाएं.
  • Authorized Buyers की उपयोगकर्ता की सूचियों को मैनेज करना.
  • प्री-टारगेटिंग कॉन्फ़िगरेशन मैनेज करें.
  • Marketplace के लिए क्लाइंट ऐक्सेस कॉन्फ़िगर करें.
  • Marketplace में डील के लिए प्रस्ताव ढूंढें और उन्हें मैनेज करें.

अगर आपको Authorized Buyers के बारे में कोई जानकारी नहीं है, तो ज़्यादा जानने के लिए, Authorized Buyers सहायता केंद्र और यूज़र इंटरफ़ेस (यूआई) पर जाएं.

पुष्टि करने की सुविधा सेट अप करें

Google API, पुष्टि करने और अनुमति देने के लिए OAuth 2.0 प्रोटोकॉल का इस्तेमाल करता है. यहां OAuth 2.0 का इस्तेमाल करके, रीयल-टाइम बिडिंग एपीआई के लिए पुष्टि करने की सुविधा सेट अप करने का तरीका बताया गया है.

इस उदाहरण में, सेवा खाते का इस्तेमाल किया गया है. ऐक्सेस कंट्रोल के बारे में ज़्यादा जानने के लिए, Google CloudIdentity ऐक्सेस मैनेजमेंट दस्तावेज़ देखें.

  1. 'Google API कंसोल से चालू किए गए एपीआई' पेज पर जाएं.

  2. प्रोजेक्ट के ड्रॉप-डाउन मेन्यू से, कोई प्रोजेक्ट चुनें या नया प्रोजेक्ट बनाएं.

  3. पक्का करें कि चालू किए गए एपीआई की सूची में रीयल-टाइम बिडिंग एपीआई मौजूद हो. अगर यह सूची में नहीं है, तो Google API टैब पर क्लिक करें, रीयल-टाइम बिडिंग एपीआई खोजें और चुनें. इसके बाद, एपीआई चालू करें पर क्लिक करें.

  4. इसके बाद, बाईं ओर साइडबार में क्रेडेंशियल चुनें.

  5. क्रेडेंशियल बनाएं ड्रॉप-डाउन चुनें. इसके बाद, सेवा खाता कुंजी चुनें.

  6. सेवा खाता ड्रॉप-डाउन में, नया सेवा खाता चुनें.

  7. सेवा खाते के लिए, नाम डालें. सेवा खाता आईडी, नाम और प्रोजेक्ट के नाम से अपने-आप जनरेट होता है.

  8. सेवा खाता आईडी नोट करें: आपको चरण 11 में, Authorized Buyers यूज़र इंटरफ़ेस (यूआई) में नए सेवा खाते का ऐक्सेस देना होगा.

  9. सुझाई गई JSON फ़ाइल को कुंजी टाइप के तौर पर चुनें.

  10. बनाएं पर क्लिक करें. खाते के सार्वजनिक/निजी कुंजी के जोड़े वाली JSON फ़ाइल आपके डाउनलोड फ़ोल्डर में सेव की जाती है. जनरेट की गई JSON फ़ाइल को किसी सुरक्षित जगह पर रखें.

  11. सेवा खाते का ऐक्सेस, Authorized Buyers यूज़र इंटरफ़ेस (यूआई) में दिखना ज़रूरी है. सेटिंग > खाता सेटिंग चुनें. इसके बाद, यूज़र मैनेजमेंट > खाता उपयोगकर्ता चुनें और +सेवा खाता पर क्लिक करें. वह सेवा खाता आईडी डालें जिसके बारे में आपने ऊपर आठवें चरण में बताया है. इससे सेवा खाते की भूमिका वाला एक नया उपयोगकर्ता बन जाता है.

पक्का करें कि कई लोगों के पास आपके क्लाउड प्रोजेक्ट का एडमिन ऐक्सेस हो, ताकि आपको अनुमतियां बदलनी पड़ें.

एपीआई ऐक्सेस का अनुरोध करें

OAuth 2.0 के ऑथराइज़ेशन फ़्लो के ज़रिए, आपका ऐप्लिकेशन दूसरे Google खातों की ओर से कुछ सुविधाओं का ऐक्सेस पाने का अनुरोध करने के लिए दायरे तय कर सकता है. किसी Authorized Buyers खाते की ओर से, किसी भी Authorized Buyers API को पढ़ने/लिखने का ऐक्सेस पाने के लिए, इन दायरों का इस्तेमाल करें:

  • मार्केटप्लेस एपीआई: https://www.googleapis.com/auth/certified- डिसप्ले-मार्केटप्लेस
  • रीयल-टाइम बिडिंग एपीआई: https://www.googleapis.com/auth/Realtime-sharing
  • Ad Exchange Buyer API II: https://www.googleapis.com/auth/ad फूल.अपनाएं

एपीआई कॉल करें

यहां कुछ सैंपल दिए गए हैं जिनका इस्तेमाल, Google पर काम करने वाली भाषाओं में शुरू करने के लिए किया जा सकता है:

मार्केटप्लेस एपीआई

Java

/*
 * Copyright 2021 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 com.google.api.services.samples.authorizedbuyers.marketplace.v1;

import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplace;
import com.google.api.services.authorizedbuyersmarketplace.v1.AuthorizedBuyersMarketplaceScopes;
import com.google.api.services.authorizedbuyersmarketplace.v1.model.Client;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.oauth2.ServiceAccountCredentials;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * A sample application that authenticates and runs a request against the Authorized Buyers
 * Marketplace API.
 */
public class FirstApiRequest {

  /**
   * Be sure to specify the name of your application. If the application name is {@code null} or
   * blank, the application will log a warning. Suggested format is "MyCompany-ProductName/1.0".
   */
  private static final String APPLICATION_NAME = "APPLICATION_NAME_HERE";

  // Full path to JSON Key file - include file name.
  private static final java.io.File JSON_FILE = new java.io.File("INSERT_PATH_TO_JSON_FILE");

  // Name of the buyer resource for which the API call is being made.
  private static final String BUYER_NAME = "INSERT_BUYER_RESOURCE_NAME";

  // Global instance of the HTTP transport.
  private static HttpTransport httpTransport;

  // Global instance of the JSON factory.
  private static final JsonFactory jsonFactory = GsonFactory.getDefaultInstance();

  public static void main(String[] args) throws Exception {
    // Create credentials using the JSON key file.
    GoogleCredentials credentials = null;

    try (FileInputStream serviceAccountStream = new FileInputStream((JSON_FILE))) {
      Set<String> scopes = new HashSet<>(AuthorizedBuyersMarketplaceScopes.all());
      credentials = ServiceAccountCredentials.fromStream(serviceAccountStream).createScoped(scopes);
    } catch (IOException ex) {
      System.out.println("Can't complete authorization step. Did you specify a JSON key file?");
      System.out.println(ex);
      System.exit(1);
    }

    HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);
    httpTransport = GoogleNetHttpTransport.newTrustedTransport();

    // Use the credentials to create a client for the API service.
    AuthorizedBuyersMarketplace marketplaceClient =
        new AuthorizedBuyersMarketplace.Builder(httpTransport, jsonFactory, requestInitializer)
            .setApplicationName(APPLICATION_NAME)
            .build();

    // Call the buyers.clients.list method to get a list of clients for the given buyer.
    List<Client> clients =
        marketplaceClient.buyers().clients().list(BUYER_NAME).execute().getClients();

    if (clients != null && clients.size() > 0) {
      System.out.printf("Listing of clients associated with buyer \"%s\"%n", BUYER_NAME);
      for (Client client : clients) {
        System.out.printf("* Client name: %s\n", client.getName());
      }
    } else {
      System.out.printf(
          "No clients were found that were associated with buyer \"%s\"%n.", BUYER_NAME);
    }
  }
}

Python

#!/usr/bin/python
#
# Copyright 2022 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.

"""Sample application that authenticates and makes an API request."""

import pprint
from googleapiclient.discovery import build
from google.oauth2 import service_account

# A Service Account key file can be generated via the Google Developers
# Console.
KEY_FILE = 'PATH_TO_JSON_KEY_FILE'  # Path to Service Account JSON key file.

# Authorized Buyers Marketplace API authorization scope.
SCOPE = 'https://www.googleapis.com/auth/authorized-buyers-marketplace'
VERSION = 'v1'  # Version of Authorized Buyers Marketplace API to use.

# Name of the buyer resource for which the API call is being made.
BUYER_NAME = 'BUYER_RESOURCE_NAME'


def main():
  # Create credentials using the Service Account JSON key file.
  credentials = service_account.Credentials.from_service_account_file(
      KEY_FILE, scopes=[SCOPE])

  # Build a client for the authorizedbuyersmarketplace API service.
  marketplace = build('authorizedbuyersmarketplace', VERSION, credentials=credentials)

  # Call the buyers.clients.list method to get a list of clients for the
  # given buyer.
  request = marketplace.buyers().clients().list(parent=BUYER_NAME)

  pprint.pprint(request.execute())


if __name__ == '__main__':
  main()

.NET

/* Copyright 2021 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
 *
 *     http://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.
 */

using Google.Apis.AuthorizedBuyersMarketplace.v1;
using Google.Apis.AuthorizedBuyersMarketplace.v1.Data;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Json;
using Google.Apis.Services;

using System;
using System.Collections.Generic;

namespace Google.Apis.AuthorizedBuyersMarketplace.Examples.v1
{
    /// <summary>
    /// Self contained sample to return a list of clients for a given buyer account.
    /// Primarily used by the Getting Started guide:
    /// https://developers.google.com/authorized-buyers/apis/getting_started
    ///
    /// Note: To run this sample, you will need to configure it as the StartupObject in
    /// Google.Apis.AuthorizedBuyersMarketplace.Examples.csproj.
    /// </summary>
    internal class FirstApiRequest
    {
        private static void Main(string[] args)
        {
            // See the README.md for details of these fields.
            // Retrieved from https://console.developers.google.com
            var ServiceKeyFilePath = "PATH TO JSON KEY FILE HERE";

            // Name of the buyer resource for which the API call is being made.
            var buyerName = "INSERT_BUYER_RESOURCE_NAME_HERE";

            // Retrieve credential parameters from the key JSON file.
            var credentialParameters = NewtonsoftJsonSerializer.Instance
                .Deserialize<JsonCredentialParameters>(
                    System.IO.File.ReadAllText(ServiceKeyFilePath));

            // Create the credentials.
            var credentialInitializer = new ServiceAccountCredential.Initializer(
                    credentialParameters.ClientEmail)
                {
                    Scopes = new[]
                    {
                        AuthorizedBuyersMarketplaceService.Scope.AuthorizedBuyersMarketplace
                    }
                }.FromPrivateKey(credentialParameters.PrivateKey);

            var oAuth2Credentials = new ServiceAccountCredential(credentialInitializer);

            // Use the credentials to create a client for the API service.
            var serviceInitializer = new BaseClientService.Initializer
                {
                    HttpClientInitializer = oAuth2Credentials,
                    ApplicationName = "FirstAPICall"
                };

            var mkService = new AuthorizedBuyersMarketplaceService(serviceInitializer);

            // Call the buyers.clients.list method to list clients for the given buyer.
            BuyersResource.ClientsResource.ListRequest request =
                mkService.Buyers.Clients.List(buyerName);

            IList<Client> clients = request.Execute().Clients;

            foreach (Client client in clients)
            {
                Console.WriteLine("* Client name: {0}", client.Name);
            }

            Console.ReadLine();
        }
    }
}

PHP

<?php

/**
 * Copyright 2022 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.
 */

/**
 * Sample application that authenticates and makes an API request.
 */

namespace Google\Ads\AuthorizedBuyers\Marketplace\Examples\V1;

/**
 * Provide path to client library. See README.md for details.
 */
require_once __DIR__ . '/../../vendor/autoload.php';

use Google_Client;
use Google_Service_AuthorizedBuyersMarketplace;


session_start();

/**
 * You can retrieve this file from the Google Developers Console.
 *
 * See README.md for details.
 */
$keyFileLocation = "INSERT_PATH_TO_JSON_KEYFILE";

/**
 * Name of the buyer resource for which the API call is being made.
 */
$buyerName = "INSERT_BUYER_RESOURCE_NAME";

if ($keyFileLocation === 'INSERT_PATH_TO_JSON_KEYFILE') {
    print "WARNING: Authorization details not provided!\n";
    exit(1);
}

$client = new Google_Client();
$client->setApplicationName('Authorized Buyers Marketplace API PHP Samples');

$service = new Google_Service_AuthorizedBuyersMarketplace($client);

$client->setAuthConfig($keyFileLocation);
$client->addScope('https://www.googleapis.com/auth/authorized-buyers-marketplace');

if ($client->isAccessTokenExpired()) {
    $client->refreshTokenWithAssertion();
}

if ($client->getAccessToken()) {
    // Call the buyers.clients.list method to get a list of clients for the given buyer.
    $result = $service->buyers_clients->listBuyersClients($buyerName);

    print "Clients associated with buyer account\n";
    if (empty($result['clients'])) {
        print "No clients found\n";
        return;
    } else {
        foreach ($result['clients'] as $client) {
            print_r($client);
        }
    }
}

Ruby

#!/usr/bin/env ruby
# Encoding: utf-8
#
# Copyright:: Copyright 2022 Google LLC
#
# License:: 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
#
#           http://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.
#
# Sample application that authenticates and makes an API request.

require 'google/apis/authorizedbuyersmarketplace_v1'
require 'googleauth/service_account'

# You can download the JSON keyfile used for authentication from the Google
# Developers Console.
KEY_FILE = 'path_to_key'  # Path to JSON file containing your private key.

# Name of the buyer resource for which the API call is being made.
BUYER_NAME = 'insert_buyer_resource_name'


def first_api_request()
  # Create credentials using the JSON key file.
  auth_options = {
    :json_key_io => File.open(KEY_FILE, "r"),
    :scope => 'https://www.googleapis.com/auth/authorized-buyers-marketplace'
  }

  oauth_credentials = Google::Auth::ServiceAccountCredentials.make_creds(
    options=auth_options
  )

  # Create the service and set credentials
  marketplace = (
    Google::Apis::AuthorizedbuyersmarketplaceV1::AuthorizedBuyersMarketplaceService.new
  )
  marketplace.authorization = oauth_credentials
  marketplace.authorization.fetch_access_token!

  begin
    # Call the buyers.clients.list method to get list of clients for given buyer.
    clients_list = marketplace.list_buyer_clients(BUYER_NAME)

    if clients_list.clients.any?
      puts "Found the following clients for buyer '%s':" % BUYER_NAME
      clients_list.clients.each do |client|
        puts "* Client name: #{client.name}"
      end
    else
      puts "No clients were found that were associated with buyer '%s'" % BUYER_NAME
    end
  rescue Google::Apis::ServerError => e
    raise "The following server error occured:\n%s" % e.message
  rescue Google::Apis::ClientError => e
    raise "Invalid client request:\n%s" % e.message
  rescue Google::Apis::AuthorizationError => e
    raise "Authorization error occured:\n%s" % e.message
  end
end

if __FILE__ == $0
  begin
    first_api_request()
  end
end

Real-time Bidding API

Java

यहां एक बुनियादी उदाहरण दिया गया है, जिसमें Java के साथ रीयल-टाइम बिडिंग एपीआई को इस्तेमाल करने का तरीका बताया गया है.

  1. Maven प्रोजेक्ट बनाना

    pom.xml खोलें और ये डिपेंडेंसी जोड़ें:

    <dependencies>
      <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <version>1.32.2</version>
      </dependency>
      <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-pubsub</artifactId>
        <version>v1-rev452-1.25.0</version>
      </dependency>
      <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-realtimebidding</artifactId>
        <version>v1-rev20220503-1.32.1</version>
      </dependency>
      <dependency>
        <groupId>com.google.auth</groupId>
        <artifactId>google-auth-library-oauth2-http</artifactId>
        <version>1.3.0</version>
      </dependency>
      <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.9</version>
      </dependency>
      <dependency>
        <groupId>com.google.http-client</groupId>
        <artifactId>google-http-client-jackson2</artifactId>
        <version>1.40.1</version>
      </dependency>
      <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>2.10.13</version>
      </dependency>
      <dependency>
        <groupId>net.sourceforge.argparse4j</groupId>
        <artifactId>argparse4j</artifactId>
        <version>0.9.0</version>
      </dependency>
    </dependencies>
      

  2. अपने क्रेडेंशियल सेट अप करना

    एपीआई के सभी कॉल के लिए पुष्टि करना ज़रूरी है. सेवा खाते की JSON कुंजी वाली फ़ाइल का इस्तेमाल करके, Credential बनाएं, जिसके बारे में ऊपर बताया गया है.

    GoogleCredentials credentials = null;
    
    try (FileInputStream serviceAccountStream = new FileInputStream((JSON_FILE))) {
      Set<String> scopes = new HashSet<>(RealTimeBiddingScopes.all());
      credentials = ServiceAccountCredentials.fromStream(serviceAccountStream).createScoped(scopes);
    } catch (IOException ex) {
      System.out.println("Can't complete authorization step. Did you specify a JSON key file?");
      System.out.println(ex);
      System.exit(1);
    }
  3. रीयल-टाइम बिडिंग एपीआई के लिए क्लाइंट बनाना

    इसके बाद, बिल्डर पैटर्न का इस्तेमाल करके, रीयल-टाइम बिडिंग एपीआई क्लाइंट बनाया जा सकता है:

    
    HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);
    httpTransport = GoogleNetHttpTransport.newTrustedTransport();
    
    // Use the credentials to create a client for the API service.
    RealTimeBidding realtimeBidding =
        new RealTimeBidding.Builder(httpTransport, jsonFactory, requestInitializer)
            .setApplicationName(APPLICATION_NAME)
            .build();

  4. कोई कार्रवाई करना

    एपीआई से कनेक्ट करने के लिए किसी क्लाइंट को इंस्टैंशिएट करने के बाद, कोई कार्रवाई की जा सकती है. यह कोड दिए गए खरीदार के सभी क्रिएटिव दिखाता है.

        List<Creative> creatives =
            realtimeBidding
                .buyers()
                .creatives()
                .list(BUYER_NAME)
                .setView("FULL")
                .execute()
                .getCreatives();
    
        if (creatives != null && creatives.size() > 0) {
          System.out.printf("Listing of creatives associated with buyer '%s'%n", BUYER_NAME);
          for (Creative creative : creatives) {
            System.out.printf("* Creative name: %s\n", creative.getName());
          }
        } else {
          System.out.printf(
              "No creatives were found that were associated with buyer '%s'%n.", BUYER_NAME);
        }

Java के साथ रीयल-टाइम बिडिंग एपीआई का इस्तेमाल करने के बारे में ज़्यादा जानकारी के लिए, रीयल-टाइम बिडिंग एपीआई के उदाहरणों में README फ़ाइल देखें.

Python

यहां एक बुनियादी उदाहरण दिया गया है, जिसमें Python के साथ रीयल-टाइम बिडिंग एपीआई को इस्तेमाल करने का तरीका दिखाया गया है.

  1. Google API Python Client को डाउनलोड और इंस्टॉल करना

    पीआईपी (पिक्चर में पिक्चर) का इस्तेमाल करने का उदाहरण:

    $ pip install --upgrade google-api-python-client

  2. अपने क्रेडेंशियल सेट अप करना

    एपीआई के सभी कॉल के लिए पुष्टि करना ज़रूरी है. सेवा खाते की JSON कुंजी वाली ऊपर बताई गई फ़ाइल का इस्तेमाल करके, service_account.Credentials इंस्टेंस इंस्टैंशिएट करें.

      credentials = service_account.Credentials.from_service_account_file(
          KEY_FILE, scopes=[SCOPE])
  3. रीयल-टाइम बिडिंग एपीआई के लिए क्लाइंट बनाना

    इसके बाद, service_account.Credentials इंस्टेंस का इस्तेमाल करके, रीयल-टाइम बिडिंग एपीआई क्लाइंट बनाया जा सकता है:

    realtimebidding = build('realtimebidding', VERSION, credentials=credentials)

  4. कोई कार्रवाई करना

    एपीआई से कनेक्ट करने के लिए किसी क्लाइंट को इंस्टैंशिएट करने के बाद, कोई कार्रवाई की जा सकती है. यह कोड दिए गए खरीदार के सभी क्रिएटिव दिखाता है.

    request = realtimebidding.buyers().creatives().list(parent=BUYER_NAME)
    
    pprint.pprint(request.execute())

Python के साथ Ad Exchange Buyer API का इस्तेमाल करने के बारे में ज़्यादा जानकारी के लिए, रीयल-टाइम बिडिंग एपीआई के उदाहरणों में README फ़ाइल देखें.

PHP

यहां एक बुनियादी उदाहरण दिया गया है, जिसमें बताया गया है कि PHP के साथ रीयल-टाइम बिडिंग एपीआई का इस्तेमाल कैसे किया जा सकता है.

  1. डिपेंडेंसी सेट अप करना

    अगर आपने अभी तक इसे इंस्टॉल नहीं किया है, तो Composer को डाउनलोड और इंस्टॉल करें. इसके बाद, यहां दिए गए कॉन्टेंट के साथ composer.json बनाएं:

    {
      "description": "Authorized Buyers Real-Time Bidding API PHP Samples",
      "require": {
        "php": ">=7.2",
        "google/apiclient": "^2.0"
      },
      "require-dev": {
        "squizlabs/php_codesniffer": "3.*"
      },
      "type": "project",
      "homepage": "https://github.com/googleads/authorized-buyers-rtb-api-samples/tree/master/php",
      "license": "Apache-2.0",
      "authors": [
        {
          "name": "Google",
          "homepage": "https://github.com/googleads/authorized-buyers-rtb-api-samples/graphs/contributors"
        }
      ]
    }
    

    आखिर में, डिपेंडेंसी लाइब्रेरी इंस्टॉल करने के लिए, इन्हें चलाएं:

    composer install
  2. क्लाइंट सेट अप करना

    Google_Client बनाएं और इसका इस्तेमाल Google_Service_RealTimeBidding को इंस्टैंशिएट करने के लिए करें.

    
    $client = new Google_Client();
    $client->setApplicationName('Authorized Buyers Real-time Bidding API PHP Samples');
    
    $service = new Google_Service_RealTimeBidding($client);
  3. अपने क्रेडेंशियल सेट अप करना

    एपीआई को किए जाने वाले सभी कॉल के लिए, मान्य ऐक्सेस टोकन होना ज़रूरी है. अपने क्लाइंट को कॉन्फ़िगर करें, ताकि वह OAuth 2.0 फ़्लो की प्रोसेस को पूरा कर सके.

    
    $client->setAuthConfig($keyFileLocation);
    $client->addScope('https://www.googleapis.com/auth/realtime-bidding');
    
    if ($client->isAccessTokenExpired()) {
        $client->refreshTokenWithAssertion();
    }
  4. कोई कार्रवाई करना

    एपीआई से कनेक्ट करने के लिए क्लाइंट को इंस्टैंशिएट करने और OAuth 2.0 को कॉन्फ़िगर करने के बाद, एपीआई कॉल करने के लिए इसका इस्तेमाल किया जा सकता है. यह कोड, खरीदार के सभी क्रिएटिव दिखाता है:

    $result = $service->buyers_creatives->listBuyersCreatives($buyerName, $queryParams);
    
    print "Creatives associated with buyer account\n";
    if (empty($result['creatives'])) {
        print "No creatives found\n";
        return;
    } else {
        foreach ($result['creatives'] as $creative) {
            print_r($creative);
        }
    }

PHP के साथ Ad Exchange Buyer API का इस्तेमाल करने के बारे में ज़्यादा जानकारी के लिए, रीयल-टाइम बिडिंग एपीआई के उदाहरणों में README फ़ाइल देखें.

.NET

यहां दिए गए उदाहरण में, C# के साथ रीयल-टाइम बिडिंग एपीआई को इस्तेमाल करने का तरीका बताया गया है.

  1. नया प्रोजेक्ट बनाना

    Visual Studio कोड खोलें और एक नया प्रोजेक्ट बनाएं.

  2. अपने प्रोजेक्ट में लाइब्रेरी के ज़रूरी रेफ़रंस जोड़ना

    अपने प्रोजेक्ट की *.csproj फ़ाइल में, Google.Apis, Google.Apis.Auth, Google.Apis.Core, Google.Apis.Oauth2.v2, और Google.Apis.RealTimeBidding.v1 के लिए, PackageReference एंट्री जोड़ें. उदाहरण के तौर पर, यह ऐसा दिख सकता है:

    <ItemGroup>
      <PackageReference Include="Google.Apis" Version="1.57.0" />
      <PackageReference Include="Google.Apis.Auth" Version="1.57.0" />
      <PackageReference Include="Google.Apis.Core" Version="1.57.0" />
      <PackageReference Include="Google.Apis.Oauth2.v2" Version="1.57.0.1869" />
      <PackageReference Include="Google.Apis.Pubsub.v1" Version="1.57.0.2667" />
      <PackageReference Condition="!Exists('./Google.Apis.RealTimeBidding.v1.csproj')" Include="Google.Apis.RealTimeBidding.v1" Version="1.57.0.2680" />
      <PackageReference Include="log4net" Version="2.0.13" />
      <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.4" />
      <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
      </PackageReference>
      <PackageReference Include="Mono.Options" Version="6.12.0.148" />
      <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
    </ItemGroup>

    इन डिपेंडेंसी के बारे में ज़्यादा जानकारी के लिए, https://www.nuget.org/packages/ पर जाएं.

  3. अपने क्रेडेंशियल सेट अप करना

    एपीआई के सभी कॉल के लिए पुष्टि करना ज़रूरी है. सेवा खाते के ईमेल पते और JSON फ़ाइल का इस्तेमाल करके, Credential बनाएं. इसके बारे में ऊपर बताया गया है.

    var credentialParameters = NewtonsoftJsonSerializer.Instance
        .Deserialize<JsonCredentialParameters>(
            System.IO.File.ReadAllText(ServiceKeyFilePath));
    
    // Create the credentials.
    var credentialInitializer = new ServiceAccountCredential.Initializer(
            credentialParameters.ClientEmail)
        {
            Scopes = new[] { RealTimeBiddingService.Scope.RealtimeBidding }
        }.FromPrivateKey(credentialParameters.PrivateKey);
    
    var oAuth2Credentials = new ServiceAccountCredential(credentialInitializer);
  4. रीयल-टाइम बिडिंग एपीआई के लिए क्लाइंट बनाना

    इसके बाद, RealTimeBiddingService बनाया जा सकता है:

    var serviceInitializer = new BaseClientService.Initializer
        {
            HttpClientInitializer = oAuth2Credentials,
            ApplicationName = "FirstAPICall"
        };
    
    var realtimebidding = new RealTimeBiddingService(serviceInitializer);
  5. कोई कार्रवाई करना

    एपीआई से कनेक्ट करने के लिए किसी क्लाइंट को इंस्टैंशिएट करने के बाद, कोई कार्रवाई की जा सकती है. इस कोड में, आपके क्रेडेंशियल से जुड़े खास Authorized Buyers खरीदार खाते के लिए, क्रिएटिव की सूची दी गई है.

    BuyersResource.CreativesResource.ListRequest request =
        realtimebidding.Buyers.Creatives.List(buyerName);
    request.View = BuyersResource.CreativesResource.ListRequest.ViewEnum.FULL;
    
    IList<Creative> creatives = request.Execute().Creatives;
    
    foreach (Creative creative in creatives)
    {
        Console.WriteLine("* Creative name: {0}", creative.Name);
    }

C# के साथ रीयल-टाइम बिडिंग एपीआई का इस्तेमाल करने के बारे में ज़्यादा जानकारी के लिए, रीयल-टाइम बिडिंग एपीआई के उदाहरणों में README फ़ाइल देखें.

Ruby

यहां एक बुनियादी उदाहरण दिया गया है, जिसमें Ruby के साथ रीयल-टाइम बिडिंग एपीआई को इस्तेमाल करने का तरीका दिखाया गया है.

  1. Google API Ruby Client को डाउनलोड और इंस्टॉल करना

    अगर आपने अभी तक इसे इंस्टॉल नहीं किया है, तो बंडलर को डाउनलोड और इंस्टॉल करें. इसके बाद, इस तरह के कॉन्टेंट के साथ एक Gemfile बनाएं:

    source "https://rubygems.org"
    
    ruby "2.6.0"
    
    gem 'google-apis-pubsub_v1', '0.10.0'
    gem 'google-apis-realtimebidding_v1', '~> 0.14.0'
    

    आखिर में, डिपेंडेंसी लाइब्रेरी इंस्टॉल करने के लिए, इन्हें चलाएं:

    bundle
  2. अपने क्रेडेंशियल सेट अप करना

    एपीआई के सभी कॉल के लिए पुष्टि करना ज़रूरी है. सेवा खाते के ईमेल और JSON फ़ाइल का इस्तेमाल करके क्रेडेंशियल बनाएं, जिनके बारे में ऊपर बताया गया है.

    # Create credentials using the JSON key file.
      auth_options = {
        :json_key_io => File.open(KEY_FILE, "r"),
        :scope => 'https://www.googleapis.com/auth/realtime-bidding'
      }
    
      oauth_credentials = Google::Auth::ServiceAccountCredentials.make_creds(
        options=auth_options
      )
  3. AdExchangeBuyer के लिए क्लाइंट बनाना

    इसके बाद, क्रेडेंशियल का इस्तेमाल करके अपना आधिकारिक Ad Exchange Buyer क्लाइंट बनाया जा सकता है:

    # Create the service and set credentials
      realtimebidding = (
        Google::Apis::RealtimebiddingV1::RealtimeBiddingService.new
      )
      realtimebidding.authorization = oauth_credentials
      realtimebidding.authorization.fetch_access_token!
  4. कोई कार्रवाई करना

    एपीआई से कनेक्ट करने के लिए किसी क्लाइंट को इंस्टैंशिएट करने के बाद, कोई कार्रवाई की जा सकती है. यह कोड दिए गए खरीदार के सभी क्रिएटिव दिखाता है.

    # Call the buyers.creatives.list method to get list of creatives for given buyer.
        creatives_list = realtimebidding.list_buyer_creatives(
            BUYER_NAME, view: 'FULL')
    
        if creatives_list.creatives.any?
          puts "Found the following creatives for buyer '%s':" % BUYER_NAME
          creatives_list.creatives.each do |creative|
            puts "* Creative name: #{creative.name}"
          end
        else
          puts "No creatives were found that were associated with buyer '%s'" % BUYER_NAME
        end

Ruby के साथ रीयल-टाइम बिडिंग एपीआई का इस्तेमाल करने के बारे में ज़्यादा जानकारी के लिए, रीयल-टाइम बिडिंग एपीआई के उदाहरणों में README फ़ाइल देखें.

Ad Exchange Buyer API II

Java

/*
 * Copyright (c) 2017 Google Inc.
 *
 * 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
 *
 * http://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 com.google.api.services.samples.adexchangebuyer.cmdline.v2_x;

import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient;
import com.google.api.services.adexchangebuyer2.v2beta1.AdExchangeBuyerII;
import com.google.api.services.adexchangebuyer2.v2beta1.model.AbsoluteDateRange;
import com.google.api.services.adexchangebuyer2.v2beta1.model.Client;
import com.google.api.services.adexchangebuyer2.v2beta1.model.Date;
import com.google.api.services.adexchangebuyer2.v2beta1.model.FilterSet;
import com.google.api.services.adexchangebuyer2.v2beta1.model.RealtimeTimeRange;
import com.google.api.services.adexchangebuyer2.v2beta1.model.RelativeDateRange;
import com.google.api.services.samples.adexchangebuyer.cmdline.BaseSample;
import java.io.IOException;
import java.util.List;

/**
 * This sample illustrates how to retrieve all Bidder-level Filter Sets.
 */
public class GetAllBidderLevelFilterSets extends BaseSample {
  @Override
  public ClientType getClientType() {
    return ClientType.ADEXCHANGEBUYERII;
  }

  @Override
  public String getName() {
    return "Get All Bidder-level Filter Sets.";
  }

  @Override
  public String getDescription() {
    return "Lists Filter Sets associated with the given Bidder.";
  }

  @Override
  public void execute(AbstractGoogleJsonClient client) throws IOException {
    AdExchangeBuyerII adXClient = (AdExchangeBuyerII) client;
    String bidderResourceId = getStringInput("bidderResourceId", "Enter the Bidder's resource ID");
    String ownerName = String.format("bidders/%s", bidderResourceId);
    List<FilterSet> allFilterSets = adXClient.bidders().filterSets().list(ownerName).execute()
        .getFilterSets();

    if (allFilterSets != null && allFilterSets.size() > 0) {
      System.out.println("========================================");
      System.out.printf("Listing of Filter Sets associated with Bidder \"%s\"%n", ownerName);
      System.out.println("========================================");
      for (FilterSet filterSet : allFilterSets) {
        System.out.printf("* Filter Set name: %s%n", filterSet.getName());
        AbsoluteDateRange absDateRange = filterSet.getAbsoluteDateRange();
        if(absDateRange != null) {
          System.out.println("AbsoluteDateRange");
          System.out.printf("\tStart date: %s%n",
              convertDateToString(absDateRange.getStartDate()));
          System.out.printf("\tEnd date: %s%n",
              convertDateToString(absDateRange.getEndDate()));
        }
        RelativeDateRange relDateRange = filterSet.getRelativeDateRange();
        if(relDateRange != null) {
          Integer offset = relDateRange.getOffsetDays();
          System.out.println("RelativeDateRange");
          System.out.printf("\tOffset days: %s%n", offset != null ? offset : 0);
          System.out.printf("\tDuration days: %s%n", relDateRange.getDurationDays());
        }
        RealtimeTimeRange rtTimeRange = filterSet.getRealtimeTimeRange();
        if(rtTimeRange != null) {
          System.out.println("RealtimeTimeRange");
          System.out.printf("\tStart timestamp: %s%n", rtTimeRange.getStartTimestamp());
        }
        String timeSeriesGranularity = filterSet.getTimeSeriesGranularity();
        if(timeSeriesGranularity != null) {
          System.out.printf("Time series granularity: %s%n", timeSeriesGranularity);
        }
        String format = filterSet.getFormat();
        if(format != null) {
          System.out.printf("\tFormat: %s%n", format);
        }
        String environment = filterSet.getEnvironment();
        if(environment != null) {
          System.out.printf("Environment: %s%n", environment);
        }
        List<String> platforms = filterSet.getPlatforms();
        if(platforms != null) {
          System.out.println("Platforms:");
          for(String platform : platforms) {
            System.out.printf("\t%s%n", platform);
          }
        }
        List<Integer> sellerNetworkIds = filterSet.getSellerNetworkIds();
        if(filterSet.getSellerNetworkIds() != null) {
          System.out.println("Seller network IDS:");
          for(Integer sellerNetworkId : sellerNetworkIds) {
            System.out.printf("\t%d%n", sellerNetworkId);
          }
        }
      }
    } else {
      System.out.printf("No Filter Sets were found associated with Bidder \"%s\"%n", ownerName);
    }
  }

  private String convertDateToString(Date date) {
    return String.format("%d%02d%02d", date.getYear(), date.getMonth(), date.getDay());
  }
}

Python

#!/usr/bin/python
#
# Copyright 2017 Google Inc. All Rights Reserved.
#
# 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
#
#      http://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.

"""This example lists bidder-level filter sets."""


import argparse
import os
import pprint
import sys

sys.path.insert(0, os.path.abspath('..'))

from googleapiclient.errors import HttpError
import samples_util


_OWNER_NAME_TEMPLATE = 'bidders/{bidders_resource_id}'

DEFAULT_BIDDER_RESOURCE_ID = 'ENTER_BIDDER_RESOURCE_ID_HERE'


def main(ad_exchange_buyer, owner_name):
  try:
    # Construct and execute the request.
    filter_sets = ad_exchange_buyer.bidders().filterSets().list(
        ownerName=owner_name).execute()
    print(f'Listing FilterSets for bidder: "{owner_name}".')
    pprint.pprint(filter_sets)
  except HttpError as e:
    print(e)


if __name__ == '__main__':
  parser = argparse.ArgumentParser(
      description='Creates a bidder-level filter set with the specified options'
  )
  # Required fields.
  parser.add_argument(
      '-b', '--bidder_resource_id', default=DEFAULT_BIDDER_RESOURCE_ID,
      help=('The resource ID of the bidders resource for which the filter '
            'sets were created. This will be used to construct the ownerName '
            'used as a path parameter for filter set requests. For additional '
            'information on how to configure the ownerName path parameter, '
            'see: https://developers.google.com/authorized-buyers/apis/'
            'reference/rest/v2beta1/bidders.filterSets/list'
            '#body.PATH_PARAMETERS.owner_name'))

  args = parser.parse_args()

  try:
    service = samples_util.GetService('v2beta1')
  except IOError as ex:
    print(f'Unable to create adexchangebuyer service - {ex}')
    print('Did you specify the key file in samples_util.py?')
    sys.exit(1)

  main(service, _OWNER_NAME_TEMPLATE.format(
           bidders_resource_id=args.bidder_resource_id))

PHP

<?php
/**
 * Copyright 2017 Google Inc.
 *
 * 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
 *
 * http://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.
 */

require_once __DIR__ . '/../../BaseExample.php';

/**
 * This example illustrates how to retrieve all Bidder-level Filter Sets.
 */
class ListBidderLevelFilterSets extends BaseExample {

  /**
   * @see BaseExample::getInputParameters()
   */
  protected function getInputParameters() {
    return [
        [
            'name' => 'bidderResourceId',
            'display' => 'Bidder Resource ID',
            'required' => true
        ]
    ];
  }

  /**
   * @see BaseExample::run()
   */
  public function run() {
    $values = $this->formValues;
    $ownerName = sprintf(
        'bidders/%s',
        $values['bidderResourceId']
    );
    $result = $this->service->bidders_filterSets
        ->listBiddersFilterSets($ownerName);
    print sprintf(
        '<h2>Listing Bidder-level Filter Sets for ownerName "%s"</h2>',
         $ownerName
    );
    if (empty($result['filterSets'])) {
      print '<p>No Bidder-level Filter Sets found.</p>';
    } else {
      foreach ($result['filterSets'] as $filterSets) {
        $this->printResult($filterSets);
      }
    }
  }

  /**
   * @see BaseExample::getClientType()
   */
  public function getClientType() {
    return ClientType::AdExchangeBuyerII;
  }

  /**
   * @see BaseExample::getName()
   */
  public function getName() {
    return 'RTB Troubleshooting: List Bidder-level Filter Sets';
  }
}

.NET

/* Copyright 2017, Google Inc. All Rights Reserved.
 *
 * 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
 *
 *     http://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.
 */

using Google.Apis.AdExchangeBuyerII.v2beta1;
using Google.Apis.AdExchangeBuyerII.v2beta1.Data;
using Google.Apis.Services;

using System;
using System.Collections.Generic;

namespace Google.Apis.AdExchangeBuyer.Examples.v2_x
{
    /// <summary>
    /// Retrieves the bidder-level filter sets for the given bidder resource ID.
    /// </summary>
    public class ListBidderLevelFilterSets : ExampleBase
    {
        /// <summary>
        /// Main method, to run this code example as a standalone application.
        /// </summary>
        /// <param name="args">The command line arguments</param>
        public static void Main(string[] args)
        {
            AdExchangeBuyerIIService service = Utilities.GetV2Service();
            ExampleBase example = new ListBidderLevelFilterSets();
            Console.WriteLine(example.Description);

            example.Run(service);
        }

        /// <summary>
        /// Returns a description about the code example.
        /// </summary>
        public override string Description
        {
            get { return "This code example lists all bidder-level filter sets for the given " +
                    "bidder resource ID."; }
        }

        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="service">An authenticated AdExchangeBuyerIIService</param>
        public override void Run(BaseClientService service)
        {
            AdExchangeBuyerIIService adXService = (AdExchangeBuyerIIService)service;
            string bidderResourceId = "INSERT_BIDDER_RESOURCE_ID_HERE";
            string ownerName = String.Format("bidders/{0}", bidderResourceId);

            ListFilterSetsResponse response = adXService.Bidders.FilterSets.List(ownerName)
                .Execute();

            Console.WriteLine("========================================\n");
            Console.WriteLine("Listing of filter sets associated with owner name \"{0}\"",
                ownerName);
            Console.WriteLine("========================================\n");

            if (response.FilterSets.Count == 0)
            {
                Console.WriteLine("No filter sets found.");
            } else
            {
                foreach (FilterSet filterSet in response.FilterSets)
                {
                    Console.WriteLine("* Name: {0}", filterSet.Name);
                    AbsoluteDateRange absDateRange = filterSet.AbsoluteDateRange;
                    if (absDateRange != null)
                    {
                        Console.WriteLine("\tAbsoluteDateRange:");
                        Date startDate = absDateRange.StartDate;
                        Console.WriteLine("\t\tStartDate:");
                        Console.WriteLine("\t\t\tYear: {0}", startDate.Year);
                        Console.WriteLine("\t\t\tMonth: {0}", startDate.Month);
                        Console.WriteLine("\t\t\tDay: {0}", startDate.Day);
                        Date endDate = absDateRange.EndDate;
                        Console.WriteLine("\t\tEndDate:");
                        Console.WriteLine("\t\t\tYear: {0}", endDate.Year);
                        Console.WriteLine("\t\t\tMonth: {0}", endDate.Month);
                        Console.WriteLine("\t\t\tDay: {0}", endDate.Day);
                    }
                    RelativeDateRange relDateRange = filterSet.RelativeDateRange;
                    if (relDateRange != null)
                    {
                        Console.WriteLine("\tRelativeDateRange:");
                        Console.WriteLine("\t\tOffsetDays: {0}", relDateRange.OffsetDays);
                        Console.WriteLine("\t\tDurationDays: {0}", relDateRange.DurationDays);
                    }
                    RealtimeTimeRange rtTimeRange = filterSet.RealtimeTimeRange;
                    if (rtTimeRange != null)
                    {
                        Console.WriteLine("\tRealtimeTimeRange:");
                        Console.WriteLine("\t\tStartTimestamp: {0}", rtTimeRange.StartTimestamp);
                    }
                    String timeSeriesGranularity = filterSet.TimeSeriesGranularity;
                    if (timeSeriesGranularity != null)
                    {
                        Console.WriteLine("\tTimeSeriesGranularity: {0}", timeSeriesGranularity);
                    }
                    IList<String> formats = filterSet.Formats;
                    if (formats != null)
                    {
                        Console.WriteLine("\tFormats:");
                        foreach (string format in formats)
                        {
                            Console.WriteLine("\t\t{0}", format);
                        }
                    }
                    String environment = filterSet.Environment;
                    if (environment != null)
                    {
                        Console.WriteLine("\tEnvironment: {0}", environment);
                    }
                    IList<string> platforms = filterSet.Platforms;
                    if (platforms != null)
                    {
                        Console.WriteLine("\tPlatforms:");
                        foreach (string platform in platforms)
                        {
                            Console.WriteLine("\t\t{0}", platform);
                        }
                    }
                    IList<int?> sellerNetworkIds = filterSet.SellerNetworkIds;
                    if (sellerNetworkIds != null)
                    {
                        Console.WriteLine("\tSellerNetworkIds:");
                        foreach (int? sellerNetworkId in sellerNetworkIds)
                        {
                            Console.WriteLine("\t\t{0}", sellerNetworkId);
                        }
                    }
                }
            }
        }

        public override ClientType getClientType()
        {
            return ClientType.ADEXCHANGEBUYERII;
        }
    }
}

Ruby

#!/usr/bin/env ruby
# Encoding: utf-8
#
# Copyright:: Copyright 2017, Google Inc. All Rights Reserved.
#
# License:: 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
#
#           http://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.
#
# Lists the filter sets for a given bidder.
#
# Tags: Bidders.FilterSets.list

require 'optparse'

require_relative '../samples_util'


def list_bidder_level_filter_sets(ad_exchange_buyer, owner_name, page_size)
  begin
    response = ad_exchange_buyer.list_bidder_filter_sets(
        owner_name, page_size: page_size
    )

    unless response.filter_sets.nil?
      puts 'Found the following filter sets for bidder %s:' % owner_name
      response.filter_sets.each do |filter_set|
        puts '* Filter set name: %s' % filter_set.name
        if !filter_set.absolute_date_range.nil?
          abs_date_range = filter_set.absolute_date_range
          start_date = abs_date_range.start_date
          end_date = abs_date_range.end_date
          puts "\tAbsolute date range:"
          puts "\t\tStart date: %s-%s-%s" % [start_date.year, start_date.month,
              start_date.day]
          puts "\t\tEnd date: %s-%s-%s" % [end_date.year, end_date.month,
              end_date.day]
        end
        unless filter_set.realtime_time_range.nil?
          realtime_time_range = filter_set.realtime_time_range
          puts "\tRealtime time range:"
          puts "\t\tStart timestamp: %s" % realtime_time_range.start_timestamp
        end
        unless filter_set.relative_date_range.nil?
          relative_date_range = filter_set.relative_date_range
          puts "\tRelative date range:"
          puts "\t\tOffset days: %s" % relative_date_range.offset_days
          puts "\t\tDuration days: %s" % relative_date_range.duration_days
        end
        unless filter_set.time_series_granularity.nil?
          puts "\tTime series granularity: %s" %
              filter_set.time_series_granularity
        end
        unless filter_set.format.nil?
          puts "\tFormat: %s" % filter_set.format
        end
        unless filter_set.environment.nil?
          puts "\tEnvironment: %s" % filter_set.environment
        end
        unless filter_set.platforms.nil?
          puts "\tPlatforms: %s" % filter_set.platforms.inspect
        end
        unless filter_set.seller_network_ids.nil?
          puts "\tSeller network IDs: %s" %
              filter_set.seller_network_ids.inspect
        end
      end
    else
      puts 'No filter sets found for bidder %s.' % owner_name
    end
  rescue Google::Apis::ServerError => e
    raise "The following server error occured:\n%s" % e.message
  rescue Google::Apis::ClientError => e
    raise "Invalid client request:\n%s" % e.message
  rescue Google::Apis::AuthorizationError => e
    raise "Authorization error occured:\n%s" % e.message
  end
end


if __FILE__ == $0
  begin
    # Retrieve the service used to make API requests.
    service = get_service(ADEXCHANGEBUYER_V2BETA1)
  rescue ArgumentError => e
    raise 'Unable to create service, with error message: %s' % e.message
  rescue Signet::AuthorizationError => e
    raise ('Unable to create service, was the KEY_FILE in samples_util.rb ' +
           'set? Error message: %s') % e.message
  end

  # Set options and default values for fields used in this example.
  options = [
    Option.new(
      'bidder_resource_id',
      ('The resource ID of the bidders resource for which the filter ' +
       'sets were created. This will be used to construct the ownerName ' +
       'used as a path parameter for filter set requests. For additional ' +
       'information on how to configure the ownerName path parameter, ' +
       'see: https://developers.google.com/authorized-buyers/apis/reference/' +
       'rest/v2beta1/bidders.filterSets/list#body.PATH_PARAMETERS.owner_name'),
      :short_alias => 'b', :required => true,
      :default_value => nil  # Insert default value here.
    ),
    Option.new(
      'max_page_size',
      'The maximum number of entries returned on one result page.',
      :type => Integer, :short_alias => 'm', :required => true,
      :default_value => MAX_PAGE_SIZE
    )
  ]

  # Parse options.
  parser = Parser.new(options)
  opts = parser.parse(ARGV)

  owner_name = 'bidders/%s' % opts['bidder_resource_id']

  list_bidder_level_filter_sets(service, owner_name, opts['max_page_size'])
end

अगले चरण

सर्वे में हिस्सा लें

इस दस्तावेज़ को बेहतर बनाने में हमारी मदद करें: एक छोटे सर्वे को भरकर, हमें बताएं कि क्या कारगर साबित हुआ और हमसे क्या छूट गया.