시작하기

Campaign Manager 360 API를 사용하면 Campaign Manager 360 계정 캠페인과 보고서를 관리하고 만드는 데 사용되며 Campaign Manager 360 및 보고서 작성 도구 웹 서비스에서와 동일한 방식으로 액세스할 수 있습니다

이 가이드에서는 Campaign Manager 360 API를 시작하는 방법을 설명합니다.

기본 요건

Campaign Manager 360 API를 사용하기 전에 진행해야 하는 몇 가지 기본 요건 충족:

  1. Campaign Manager 360 계정이 있어야 합니다. 자세한 내용은 가입 정보는 광고주/대행사에 문의하세요.

  2. Campaign Manager 360 계정에서 API 액세스가 사용 설정되어 있어야 합니다. 대부분 계정에는 이 기능이 기본적으로 사용 설정되어 있습니다. 확실하지 않은 경우 계정 담당자 또는 Campaign Manager 360 지원팀 지원팀에 문의하세요.

  3. 이 계정에 액세스할 수 있는 사용자 프로필이 있어야 합니다. Campaign Manager 360 계정 관리자가 이 계정에 액세스할 수 없습니다.

  4. Campaign Manager 360 UI에서 사용자 프로필 권한을 확인하세요. 이러한 제어 영역 액세스할 수 있는 항목을 지정합니다. 별도의 API 없음 권한을 부여할 수 있습니다

프로젝트 만들기

Campaign Manager 360 API를 사용하려면 먼저 또는 Google API 콘솔에서 프로젝트를 선택하고 API를 사용 설정하세요. 사용 과정을 안내하고 Campaign Manager 360 API를 활성화합니다. 자동으로 확장 및 축소할 수 있습니다

<ph type="x-smartling-placeholder">

사용자 인증 정보 만들기

Campaign Manager 360 API에 대한 모든 요청은 승인을 받아야 합니다. 간략한 설명 승인에 대한 개요를 보려면 계정 승인 및 식별 방법에 대해 Google에 제출해야 합니다.

다음 안내에서는 OAuth를 만드는 과정을 안내합니다. 설치된 애플리케이션에서 사용할 2.0 클라이언트 ID 흐름을 참조하세요. 사용할 사용자 인증 정보를 생성하는 방법에 대한 안내 서비스에 대한 자세한 내용은 서비스 계정 참조하세요.

  1. 단계에 따라 Google API 콘솔 프로젝트를 구성합니다.

  2. API 콘솔에서 사용자 인증 정보 페이지를 엽니다.
  3. 사용자 인증 정보 만들기 >를 클릭합니다. OAuth 클라이언트 ID를 입력합니다.

    1. 이 프로젝트의 OAuth 동의 화면을 구성하지 않은 경우 지금 사용하라는 안내가 표시됩니다 동의 구성 클릭 화면을 선택합니다.

    2. 사용자 유형을 선택하고 만들기를 클릭합니다.

    3. 최초 양식을 작성합니다. 필요한 경우 나중에 수정할 수 있습니다. 클릭 완료되면 저장합니다.

    4. 사용자 인증 정보 > 사용자 인증 정보 만들기 > OAuth 클라이언트 ID를 계속을 탭합니다.

  4. 애플리케이션 유형으로 데스크톱 앱을 선택하고 이름을 지정한 다음 만들기:

완료되면 OAuth 2.0 클라이언트 ID와 클라이언트가 표시됩니다. JSON 형식으로 다운로드하고 나중에 사용하기 위해 저장할 수 있습니다.

<ph type="x-smartling-placeholder">

클라이언트 라이브러리 설치

Campaign Manager 360 API는 HTTP 및 JSON에 기반하므로 모든 표준 HTTP 클라이언트에서 응답을 파싱합니다

그러나 Google API 클라이언트 라이브러리는 보안이 강화되고 승인된 요청에 대한 지원이 제공됩니다. 클라이언트 라이브러리는 다양한 프로그래밍 언어로 제공됩니다. 이를 통해 수동으로 HTTP 요청을 설정하고 응답을 파싱할 필요가 없습니다.

시작하려면 있습니다.

C#

최신 .NET용 Campaign Manager 360 API 클라이언트 라이브러리를 설치합니다. 사용 NuGet을 사용하여 설치를 관리하는 것이 좋습니다.

NuGet 패키지 관리자 콘솔을 열고 다음 명령어를 실행합니다.

Install-Package Google.Apis.Dfareporting.v3_4

자세히 알아보기

자바

최신 Java용 Campaign Manager 360 API 클라이언트 라이브러리를 설치합니다. 사용 Maven을 사용하여 설치를 관리하는 것이 좋습니다.

pom.xml 파일에 다음 종속 항목을 추가합니다.

<dependency>
  <groupId>com.google.apis</groupId>
  <artifactId>google-api-services-dfareporting</artifactId>
  <version>v4-rev20220611-1.32.1</version>
  <exclusions>
    <exclusion>
      <groupId>com.google.guava</groupId>
      <artifactId>guava-jdk5</artifactId>
    </exclusion>
  </exclusions>
</dependency>

자세히 알아보기

PHP

최신 PHP용 Campaign Manager 360 API 클라이언트 라이브러리를 설치합니다. 사용 Composer를 사용하여 설치를 관리하는 것이 좋습니다.

터미널을 열고 다음 명령어를 실행합니다.

composer require google/apiclient

이미 라이브러리를 설치했고 최신 버전:

composer update google/apiclient

시스템에 따라 명령어 앞에 sudo

자세히 알아보기

Python

최신 Python용 Campaign Manager 360 API 클라이언트 라이브러리를 설치합니다. 사용 pip를 사용하여 설치를 관리하는 것이 좋습니다.

터미널을 열고 다음 명령어를 실행합니다.

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

시스템에 따라 명령어 앞에 sudo

자세히 알아보기

Ruby

최신 Ruby용 Campaign Manager 360 API 클라이언트 라이브러리를 설치합니다. 사용 RubyGems를 사용하여 설치를 관리하는 것이 좋습니다.

터미널을 열고 다음 명령어를 실행합니다.

gem install google-api-client

이미 라이브러리를 설치했고 최신 버전:

gem update -y google-api-client

시스템에 따라 명령어 앞에 sudo

자세히 알아보기

지원되는 언어는 클라이언트에서 확인할 수 있습니다. 라이브러리 페이지를 참조하세요.

요청하기

OAuth 2.0 사용자 인증 정보 생성클라이언트 라이브러리 사용 설치되면 Campaign Manager 360 API를 사용할 준비가 된 것입니다. 자세히 알아보기 인증하고, 클라이언트를 구성하고, 첫 번째 요청을 하려면 참조하세요.

C#

  1. 클라이언트 보안 비밀 파일을 로드하고 승인 사용자 인증 정보를 생성합니다.

    이 단계를 처음 수행할 때는 브라우저에 승인 메시지를 수락하라는 메시지가 표시됩니다. 동의하기 전에 Campaign Manager 360에 액세스할 수 있는 Google 계정으로 로그인했는지 확인하세요. 애플리케이션은 현재 로그인된 계정을 대신하여 데이터에 액세스할 수 있도록 승인됩니다.

    // Load client secrets from the specified JSON file.
    GoogleClientSecrets clientSecrets;
    using(Stream json = new FileStream(pathToJsonFile, FileMode.Open, FileAccess.Read)) {
      clientSecrets = GoogleClientSecrets.Load(json);
    }
    
    // Create an asynchronous authorization task.
    //
    // Note: providing a data store allows auth credentials to be cached, so they survive multiple
    // runs of the application. This avoids prompting the user for authorization every time the
    // access token expires, by remembering the refresh token. The "user" value is used to
    // identify a specific set of credentials within the data store. You may provide different
    // values here to persist credentials for multiple users to the same data store.
    Task<UserCredential> authorizationTask = GoogleWebAuthorizationBroker.AuthorizeAsync(
        clientSecrets.Secrets,
        OAuthScopes,
        "user",
        CancellationToken.None,
        dataStore);
    
    // Authorize and persist credentials to the data store.
    UserCredential credential = authorizationTask.Result;
    
  2. 승인된 Dfareporting 클라이언트를 만듭니다.

    // Create a Dfareporting service object.
    //
    // Note: application name should be replaced with a value that identifies your application.
    service = new DfareportingService(
        new BaseClientService.Initializer {
          HttpClientInitializer = credential,
          ApplicationName = "C# installed app sample"
        }
    );
    
  3. 작업을 수행합니다.

    // Retrieve and print all user profiles for the current authorized user.
    UserProfileList profiles = service.UserProfiles.List().Execute();
    
    foreach (UserProfile profile in profiles.Items) {
      Console.WriteLine("Found user profile with ID {0} and name \"{1}\".",
          profile.ProfileId, profile.UserName);
    }
    

자바

  1. 클라이언트 보안 비밀 파일을 로드하고 승인 사용자 인증 정보를 생성합니다.

    이 단계를 처음 수행할 때는 브라우저에 승인 메시지를 수락하라는 메시지가 표시됩니다. 동의하기 전에 Campaign Manager 360에 액세스할 수 있는 Google 계정으로 로그인했는지 확인하세요. 애플리케이션은 현재 로그인된 계정을 대신하여 데이터에 액세스할 수 있도록 승인됩니다.

    // Load the client secrets JSON file.
    GoogleClientSecrets clientSecrets =
        GoogleClientSecrets.load(
            jsonFactory, Files.newBufferedReader(Paths.get(pathToClientSecretsFile), UTF_8));
    
    // Set up the authorization code flow.
    //
    // Note: providing a DataStoreFactory allows auth credentials to be cached, so they survive
    // multiple runs of the program. This avoids prompting the user for authorization every time the
    // access token expires, by remembering the refresh token.
    GoogleAuthorizationCodeFlow flow =
        new GoogleAuthorizationCodeFlow.Builder(
                httpTransport, jsonFactory, clientSecrets, OAUTH_SCOPES)
            .setDataStoreFactory(dataStoreFactory)
            .build();
    
    // Authorize and persist credentials to the data store.
    //
    // Note: the "user" value below is used to identify a specific set of credentials in the data
    // store. You may provide different values here to persist credentials for multiple users to
    // the same data store.
    Credential credential =
        new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
    
  2. 승인된 Dfareporting 클라이언트를 만듭니다.

    // Create a Dfareporting client instance.
    //
    // Note: application name below should be replaced with a value that identifies your
    // application. Suggested format is "MyCompany-ProductName/Version.MinorVersion".
    Dfareporting reporting =
        new Dfareporting.Builder(credential.getTransport(), credential.getJsonFactory(), credential)
            .setApplicationName("dfareporting-java-installed-app-sample")
            .build();
    
  3. 작업을 수행합니다.

    // Retrieve and print all user profiles for the current authorized user.
    UserProfileList profiles = reporting.userProfiles().list().execute();
    for (int i = 0; i < profiles.getItems().size(); i++) {
      System.out.printf("%d) %s%n", i + 1, profiles.getItems().get(i).getUserName());
    }
    

PHP

  1. 클라이언트 보안 비밀 파일을 로드하고 승인 사용자 인증 정보를 생성합니다.

    이 단계를 처음 수행할 때는 브라우저에 승인 메시지를 수락하라는 메시지가 표시됩니다. 동의하기 전에 Campaign Manager 360에 액세스할 수 있는 Google 계정으로 로그인했는지 확인하세요. 애플리케이션은 현재 로그인된 계정을 대신하여 데이터에 액세스할 수 있도록 승인됩니다.

    // Create a Google_Client instance.
    //
    // Note: application name should be replaced with a value that identifies
    // your application. Suggested format is "MyCompany-ProductName".
    $client = new Google_Client();
    $client->setAccessType('offline');
    $client->setApplicationName('PHP installed app sample');
    $client->setRedirectUri(self::OAUTH_REDIRECT_URI);
    $client->setScopes(self::$OAUTH_SCOPES);
    
    // Load the client secrets file.
    $client->setAuthConfig($pathToJsonFile);
    
    // Try to load cached credentials from the token store. Using a token store
    // allows auth credentials to be cached, so they survive multiple runs of
    // the application. This avoids prompting the user for authorization every
    // time the access token expires, by remembering the refresh token.
    if (file_exists($tokenStore) && filesize($tokenStore) > 0) {
        $client->setAccessToken(file_get_contents($tokenStore));
    } else {
        // If no cached credentials were found, authorize and persist
        // credentials to the token store.
        print 'Open this URL in your browser and authorize the application.';
        printf("\n\n%s\n\n", $client->createAuthUrl());
        print 'Enter the authorization code: ';
        $code = trim(fgets(STDIN));
        $client->authenticate($code);
    
        file_put_contents($tokenStore, json_encode($client->getAccessToken()));
    }
    
  2. 승인된 Dfareporting 클라이언트를 만듭니다.

    // Create a Dfareporting service object.
    $service = new Google_Service_Dfareporting($client);
    
  3. 작업을 수행합니다.

    // Retrieve and print all user profiles for the current authorized user.
    $result = $service->userProfiles->listUserProfiles();
    foreach ($result['items'] as $userProfile) {
        printf(
            "User profile \"%s\" (ID: %d) found for account %d.\n",
            $userProfile->getUserName(),
            $userProfile->getProfileId(),
            $userProfile->getAccountId()
        );
    }
    

Python

  1. 클라이언트 보안 비밀 파일을 로드하고 승인 사용자 인증 정보를 생성합니다.

    이 단계를 처음 수행할 때는 브라우저에 승인 메시지를 수락하라는 메시지가 표시됩니다. 동의하기 전에 Campaign Manager 360에 액세스할 수 있는 Google 계정으로 로그인했는지 확인하세요. 애플리케이션은 현재 로그인된 계정을 대신하여 데이터에 액세스할 수 있도록 승인됩니다.

    # Set up a Flow object to be used if we need to authenticate.
    flow = client.flow_from_clientsecrets(
        path_to_client_secrets_file, scope=OAUTH_SCOPES)
    
    # Check whether credentials exist in the credential store. Using a credential
    # store allows auth credentials to be cached, so they survive multiple runs
    # of the application. This avoids prompting the user for authorization every
    # time the access token expires, by remembering the refresh token.
    storage = Storage(CREDENTIAL_STORE_FILE)
    credentials = storage.get()
    
    # If no credentials were found, go through the authorization process and
    # persist credentials to the credential store.
    if credentials is None or credentials.invalid:
      credentials = tools.run_flow(flow, storage,
                                   tools.argparser.parse_known_args()[0])
    
    # Use the credentials to authorize an httplib2.Http instance.
    http = credentials.authorize(httplib2.Http())
    
  2. 승인된 Dfareporting 클라이언트를 만듭니다.

    # Construct a service object via the discovery service.
    service = discovery.build('dfareporting', 'v4', http=http)
    
  3. 작업을 수행합니다.

    # Construct the request.
    request = service.userProfiles().list()
    
    # Execute request and print response.
    response = request.execute()
    
    for profile in response['items']:
      print('Found user profile with ID %s and user name "%s".' %
            (profile['profileId'], profile['userName']))
    

Ruby

  1. 클라이언트 보안 비밀 파일을 로드하고 승인 사용자 인증 정보를 생성합니다.

    이 단계를 처음 수행할 때는 브라우저에 승인 메시지를 수락하라는 메시지가 표시됩니다. 동의하기 전에 Campaign Manager 360에 액세스할 수 있는 Google 계정으로 로그인했는지 확인하세요. 애플리케이션은 현재 로그인된 계정을 대신하여 데이터에 액세스할 수 있도록 승인됩니다.

    # Load client ID from the specified file.
    client_id = Google::Auth::ClientId.from_file(path_to_json_file)
    
    # Set up the user authorizer.
    #
    # Note: providing a token store allows auth credentials to be cached, so they
    # survive multiple runs of the application. This avoids prompting the user for
    # authorization every time the access token expires, by remembering the
    # refresh token.
    authorizer = Google::Auth::UserAuthorizer.new(
      client_id, [API_NAMESPACE::AUTH_DFAREPORTING], token_store
    )
    
    # Authorize and persist credentials to the data store.
    #
    # Note: the 'user' value below is used to identify a specific set of
    # credentials in the token store. You may provide different values here to
    # persist credentials for multiple users to the same token store.
    authorization = authorizer.get_credentials('user')
    if authorization.nil?
      puts format(
        "Open this URL in your browser and authorize the application.\n\n%s" \
        "\n\nEnter the authorization code:",
        authorizer.get_authorization_url(base_url: OAUTH_REDIRECT_URI)
      )
      code = STDIN.gets.chomp
      authorization = authorizer.get_and_store_credentials_from_code(
        base_url: OAUTH_REDIRECT_URI, code: code, user_id: 'user'
      )
    end
    
  2. 승인된 Dfareporting 클라이언트를 만듭니다.

    # Create a Dfareporting service object.
    #
    # Note: application name should be replaced with a value that identifies
    # your application. Suggested format is "MyCompany-ProductName".
    service = API_NAMESPACE::DfareportingService.new
    service.authorization = authorization
    service.client_options.application_name = 'Ruby installed app sample'
    service.client_options.application_version = '1.0.0'
    
  3. 작업을 수행합니다.

    // Retrieve and print all user profiles for the current authorized user.
    UserProfileList profiles = service.UserProfiles.List().Execute();
    
    foreach (UserProfile profile in profiles.Items) {
      Console.WriteLine("Found user profile with ID {0} and name \"{1}\".",
          profile.ProfileId, profile.UserName);
    }
    

자세히 알아보기

API 참조: 제공할 수 있습니다. 모든 메서드 세부정보 페이지에는 API가 삽입되어 있습니다. Explorer를 사용하여 웹 브라우저에서 직접 있습니다.

고급 주제를 다루고 종합적인 내용을 제공하는 다른 가이드를 검토하세요. 일반적인 작업의 예를 살펴보겠습니다.

코드 작성을 시작할 준비가 되면 자유롭게 코드 샘플 모음(수정 및 필요에 맞게 확장되었습니다