इस एपीआई का इस्तेमाल शुरू करें

यह दस्तावेज़ बताता है कि उन ऐप्लिकेशन को लिखना कैसे शुरू किया जाए जिनका इस्तेमाल Google बिड मैनेजर एपीआई. इस एपीआई से आपको अपनी वेबसाइट को क्वेरी और वापस पाना रिपोर्ट का मेटाडेटा.

बिड मैनेजर एपीआई v2 सबसे नया उपलब्ध है और इसका सुझाव दिया जाता है वर्शन है.

1. शुरू करने से पहले

अगर आपको Google Display & Video 360 के बारे में नहीं पता है Video 360 में उपलब्ध कॉन्सेप्ट, डिसप्ले और Video 360 सहायता केंद्र और यूज़र इंटरफ़ेस (यूआई) के साथ प्रयोग करें.

2. पुष्टि करने की तैयारी करना

Bid Manager API का इस्तेमाल शुरू करने के लिए, आपको इस्तेमाल करें सेटअप टूल की मदद से, सेटअप टूल की मदद ली जा सकती है. Google API (एपीआई) कंसोल, एपीआई चालू करना, और क्रेडेंशियल बनाना.

अगर आपने पहले से ऐसा नहीं किया है, तो क्लिक करके अपने OAuth 2.0 क्रेडेंशियल बनाएं क्रेडेंशियल बनाएं > OAuth क्लाइंट आईडी. एक बार फिर से तैयार होने के बाद क्रेडेंशियल के बिना, आप क्रेडेंशियल पेज पर अपना क्लाइंट आईडी देख सकते हैं. क्लिक करें क्लाइंट सीक्रेट, रीडायरेक्ट यूआरआई, JavaScript जैसी जानकारी के लिए क्लाइंट आईडी ऑरिजिन पता और ईमेल पता होता है.

ज़्यादा जानकारी के लिए, यह देखें अनुरोधों को अनुमति देना.

3. Bid Manager API पर कॉल करें

यहां दिए गए टैब अलग-अलग भाषाओं में कोडिंग के लिए क्विकस्टार्ट की सुविधा देते हैं. कोई अंतर नहीं सैंपल कोड को यहां भी देखा जा सकता है: बिड मैनेजर एपीआई के उदाहरण रेपो.

Java

  1. ज़रूरी लाइब्रेरी इंपोर्ट करें.

    import static java.nio.charset.StandardCharsets.UTF_8;
    import com.google.api.client.auth.oauth2.Credential;
    import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
    import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
    import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
    import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
    import com.google.api.client.googleapis.util.Utils;
    import com.google.api.services.doubleclickbidmanager.DoubleClickBidManager;
    import com.google.api.services.doubleclickbidmanager.model.ListQueriesResponse;
    import com.google.api.services.doubleclickbidmanager.model.Query;
    import java.io.Reader;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
  2. क्लाइंट सीक्रेट फ़ाइल लोड करें और अनुमति देने वाले क्रेडेंशियल जनरेट करें.

    पहली बार ऐसा करते समय, आपसे अनुमति देने के लिए कहा जाएगा प्रॉम्प्ट. स्वीकार करने से पहले, पक्का करें कि आपने वह Google खाता जिससे Display & वीडियो 360. आपके ऐप्लिकेशन को अनुमति दी जाएगी .

    // Read client secrets file.
    GoogleClientSecrets clientSecrets;
    try (Reader reader = Files.newBufferedReader(Paths.get(path-to-client-secrets-file), UTF_8)) {
      clientSecrets = GoogleClientSecrets.load(Utils.getDefaultJsonFactory(), reader);
    }
    
    // Generate authorization credentials.
    // Set up the authorization code flow.
    GoogleAuthorizationCodeFlow flow =
        new GoogleAuthorizationCodeFlow.Builder(
            Utils.getDefaultTransport(),
            Utils.getDefaultJsonFactory(),
            clientSecrets,
            oauth-scopes)
        .build();
    
    Credential credential =
        new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
    
  3. अनुमति वाला एपीआई क्लाइंट बनाएं.

    // Create authorized API client.
    DoubleClickBidManager service =
        new DoubleClickBidManager.Builder(credential.getTransport(), credential.getJsonFactory(), credential)
            .setApplicationName("bidmanager-java-installed-app-sample")
            .build();
    
  4. कोई कार्रवाई करें.

    // Perform an operation.
    // Call the API, getting a list of 10 queries.
    ListQueriesResponse queriesResponse = service.queries().list().setPageSize(10).execute();
    
    // Print them out.
    System.out.println("Id\t\tName");
    if (queriesResponse.getQueries().size() > 0) {
      for (int i = 0; i < queriesResponse.getQueries().size(); i++) {
        Query currentQuery = queriesResponse.getQueries().get(i);
        System.out.printf(
            "%s\t%s%n",
            currentQuery.getQueryId(),
            currentQuery.getMetadata().getTitle());
      }
    } else {
      System.out.println("No queries exist.");
    }
    

Java के साथ, Bid Manager API का इस्तेमाल करने के बारे में ज़्यादा जानकारी के लिए, यह देखें रीडमी फ़ाइल में Bid Manager API के उदाहरण.

Python

  1. ज़रूरी लाइब्रेरी इंपोर्ट करें.

    from google_auth_oauthlib.flow import InstalledAppFlow
    from googleapiclient import discovery
    
  2. क्लाइंट सीक्रेट फ़ाइल लोड करें और अनुमति देने वाले क्रेडेंशियल जनरेट करें.

    पहली बार ऐसा करते समय, आपसे अनुमति देने के लिए कहा जाएगा प्रॉम्प्ट. स्वीकार करने से पहले, पक्का करें कि आपने वह Google खाता जिससे Display & वीडियो 360. आपके ऐप्लिकेशन को अनुमति दी जाएगी .

    # Set up a flow object to create the credentials using the
    # client secrets file and OAuth scopes.
    credentials = InstalledAppFlow.from_client_secrets_file(
        path-to-client-secrets-file, oauth-scopes).run_local_server()
    
  3. अनुमति वाला एपीआई क्लाइंट बनाएं.

    # Build the discovery document URL.
    discovery_url = f'https://doubleclickbidmanager.googleapis.com/$discovery/rest?version=v2'
    
    # Build the API service.
    service = discovery.build(
        'doubleclickbidmanager',
        'v2',
        discoveryServiceUrl=discovery_url,
        credentials=credentials)
    
  4. कोई कार्रवाई करें.

    # Build and execute queries.listqueries request.
    response = service.queries().list(pageSize='10').execute()
    
    # Print queries out.
    if 'queries' in response:
      print('Id\t\tName')
      for query in response['queries']:
        print('%s\t%s' % (query['queryId'], query['metadata']['title']))
    else:
      print('No queries exist.')
    

Python के साथ Bid Manager API का इस्तेमाल करने के बारे में ज़्यादा जानकारी पाने के लिए, यह देखें रीडमी फ़ाइल में Bid Manager API के उदाहरण.

PHP

यह नमूना मान लेता है कि आप एक बिल्ट-इन वेब सर्वर के साथ PHP का इस्तेमाल कर रहे हैं और ने संबंधित वेब पेज पर रीडायरेक्ट करने के लिए आपके क्रेडेंशियल कॉन्फ़िगर किए हैं. इसके लिए उदाहरण के लिए, index.php फ़ाइल में इस कोड को इनका इस्तेमाल करके चलाया जा सकता है इसके बाद, http://localhost:8000 पर रीडायरेक्ट करने के लिए कॉन्फ़िगर किया गया कमांड और क्रेडेंशियल प्रमाणीकरण:

php -S localhost:8000 -t ./

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

    पसंदीदा तरीका Composer है:

    composer require google/apiclient:^2.12.1
    

    इंस्टॉल हो जाने के बाद, ऑटोलोडर को ज़रूर शामिल करें

    require_once '/path/to/your-project/vendor/autoload.php';
    
    अभी तक किसी भी व्यक्ति ने चेक इन नहीं किया है

  2. Google_Client-क्लाइंट ऑब्जेक्ट बनाएं.

    $client = new Google_Client();
    
  3. क्लाइंट सेट अप करें, ज़रूरी होने पर पुष्टि करने वाले यूआरएल पर रीडायरेक्ट करें, और ऐक्सेस टोकन फिर से पाएं.

    पहली बार ऐसा करते समय, आपसे अनुमति देने के लिए कहा जाएगा प्रॉम्प्ट. स्वीकार करने से पहले, पक्का करें कि आपने वह Google खाता जिससे Display & वीडियो 360. आपके ऐप्लिकेशन को अनुमति दी जाएगी .

    // Set up the client.
    $client->setApplicationName('DBM API PHP Samples');
    $client->addScope(oauth-scope);
    $client->setAccessType('offline');
    $client->setAuthConfigFile(path-to-client-secrets-file);
    
    // If the code is passed, authenticate. If not, redirect to authentication page.
    if (isset($_GET['code'])) {
      $client->authenticate($_GET['code']);
    } else {
      $authUrl = $client->createAuthUrl();
      header('Location: ' . $authUrl);
    }
    
    // Exchange authorization code for an access token.
    $accessToken = $client->getAccessToken();
    $client->setAccessToken($accessToken);
    
  4. Display &Video 360 के लिए, एक क्लाइंट बनाएं और Video 360 API सेवा.

    $service = new Google_Service_DoubleClickBidManager($client);
    
  5. कोई कार्रवाई करें.

    // Configure params for the Queries.listqueries request.
    $optParams = array('pageSize' => 10);
    
    // Execute the request.
    $result = $service->queries->listQueries($optParams);
    
    // Print the retrieved queries.
    if (!empty($result->getQueries())) {
      print('<pre><p>Id Name</p>');
      foreach ($result->getQueries() as $query) {
        printf('<p>%s %s</p>', $query->queryId, $query->metadata->title);
      }
      print('</pre>');
    } else {
      print '<p>No queries exist.</p>';
    }
    

PHP के साथ Bid Manager API का इस्तेमाल करने के बारे में ज़्यादा जानकारी पाने के लिए, यह देखें रीडमी फ़ाइल में बिड मैनेजर एपीआई के उदाहरण.

4. अगले चरण

अब आपकी क्लाइंट लाइब्रेरी तैयार है और चालू है, तो रेफ़रंस को एक्सप्लोर करें दस्तावेज़ बना लें और उन्हें लागू करना शुरू कर दें.

यहां अन्य गाइड भी उपलब्ध हैं शेड्यूल की गई रिपोर्ट इस्तेमाल करने का तरीका और रिपोर्ट करने के सबसे सही तरीके अपनाएं.