Mạng thử nghiệm cung cấp một môi trường dữ liệu hoàn toàn tách biệt để kiểm thử mã của bạn.

Theo mặc định, mạng thử nghiệm không phải là mạng Ad Manager 360. Nếu bạn cần thêm các tính năng bổ sung vào mạng thử nghiệm, hãy liên hệ với người quản lý tài khoản của bạn.

Mạng thử nghiệm khác với mạng chính thức ở những điểm sau:

  • Mạng thử nghiệm chỉ được phép có tối đa 10.000 đối tượng cho mỗi loại thực thể.
  • Mạng thử nghiệm không thể phân phát quảng cáo.
  • Báo cáo yêu cầu dữ liệu phân phát không chứa hàng nào.
  • Vì tính năng dự báo yêu cầu nhật ký phân phát, nên kết quả dự báo là giả.

Để tạo mạng thử nghiệm, hãy sử dụng phương thức NetworkService.provisionTestNetwork. Bạn chỉ có thể tạo một mạng thử nghiệm cho Tài khoản Google của mình.

Java

import com.google.ads.admanager.v1.Network;
import com.google.ads.admanager.v1.NetworkServiceClient;
import com.google.ads.admanager.v1.ProvisionTestNetworkRequest;

public class SyncProvisionTestNetwork {

  public static void main(String[] args) throws Exception {
    syncProvisionTestNetwork();
  }

  public static void syncProvisionTestNetwork() throws Exception {
    try (NetworkServiceClient networkServiceClient = NetworkServiceClient.create()) {
      ProvisionTestNetworkRequest request = ProvisionTestNetworkRequest.newBuilder().build();
      Network response = networkServiceClient.provisionTestNetwork(request);
    }
  }
}

Python

from google.ads import admanager_v1


def sample_provision_test_network():
    # Create a client
    client = admanager_v1.NetworkServiceClient()

    # Initialize request argument(s)
    request = admanager_v1.ProvisionTestNetworkRequest()

    # Make the request
    response = client.provision_test_network(request=request)

    # Handle the response
    print(response)

.NET

using Google.Ads.AdManager.V1;

public sealed partial class GeneratedNetworkServiceClientSnippets
{
    public void ProvisionTestNetworkRequestObject()
    {
        // Create client
        NetworkServiceClient networkServiceClient = NetworkServiceClient.Create();
        // Initialize request argument(s)
        ProvisionTestNetworkRequest request = new ProvisionTestNetworkRequest { };
        // Make the request
        Network response = networkServiceClient.ProvisionTestNetwork(request);
    }
}

PHP


use Google\Ads\AdManager\V1\Client\NetworkServiceClient;
use Google\Ads\AdManager\V1\Network;
use Google\Ads\AdManager\V1\ProvisionTestNetworkRequest;
use Google\ApiCore\ApiException;

function provision_test_network_sample(): void
{
    // Create a client.
    $networkServiceClient = new NetworkServiceClient();

    // Prepare the request message.
    $request = new ProvisionTestNetworkRequest();

    // Call the API and handle any network failures.
    try {
        $response = $networkServiceClient->provisionTestNetwork($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

Ruby

require "google/ads/ad_manager/v1"

def provision_test_network
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Ads::AdManager::V1::NetworkService::Rest::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Ads::AdManager::V1::ProvisionTestNetworkRequest.new

  # Call the provision_test_network method.
  result = client.provision_test_network request

  # The returned object is of type Google::Ads::AdManager::V1::Network.
  p result
end

Node.js


// Imports the Admanager library
const {NetworkServiceClient} = require('@google-ads/admanager').v1;

// Instantiates a client
const admanagerClient = new NetworkServiceClient();

async function callProvisionTestNetwork() {
  // Construct request
  const request = {
  };

  // Run request
  const response = await admanagerClient.provisionTestNetwork(request);
  console.log(response);
}

callProvisionTestNetwork();

cURL

Yêu cầu

curl -X POST -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -H "Content-Type: application/json" \
    -d "{}" \
    "https://admanager.googleapis.com/v1/networks:provisionTestNetwork"

Phản hồi

{
  "name": "networks/234093456",
  "displayName": "My Test Network",
  "networkCode": "234093456",
  "propertyCode": "ca-pub-0000000000000000",
  "timeZone": "America/Los_Angeles",
  "currencyCode": "USD",
  "effectiveRootAdUnit": "networks/234093456/adUnits/233093456",
  "testNetwork": true,
  "networkId": "567890"
}