Başlama

Campaign Manager 360 API, Campaign Manager 360 hesabınızdaki bilgilere programatik erişim sağlar. Campaign Manager 360 ve Rapor Oluşturucu web hizmetlerinde olduğu gibi kampanyaları ve raporları yönetmek ve oluşturmak için kullanılır.

Bu kılavuzda, Campaign Manager 360 API'yi kullanmaya nasıl başlayacağınız açıklanmaktadır.

Ön koşullar

Campaign Manager 360 API'yi kullanmadan önce karşılamanız gereken birkaç ön koşul adımı vardır:

  1. Campaign Manager 360 hesabınız olmalıdır. Kayıt bilgileri için Reklamverenler/Ajanslar bölümüne bakın.

  2. Campaign Manager 360 hesabınızda API erişimi etkinleştirilmiş olmalıdır. Çoğu hesapta bu özellik varsayılan olarak etkindir. Emin değilseniz yardım için hesap temsilcinizle veya Campaign Manager 360 destek ekibiyle iletişime geçin.

  3. Bu hesaba erişimi olan bir kullanıcı profiliniz olmalıdır. Campaign Manager 360 hesap yöneticinizden bu hesapla ilişkilendirilmiş bir kullanıcı profili oluşturmasını isteyin.

  4. Campaign Manager 360 kullanıcı arayüzünde kullanıcı profili izinlerini kontrol edin. Bu denetimler, kullanıcı profilinin API'den erişebileceği öğeleri kontrol eder. Ayrı API izinleri yoktur.

Proje oluşturma

Campaign Manager 360 API'yi kullanmaya başlamak için önce Google API Konsolu'nda bir proje oluşturmanız veya seçmeniz ve API'yi etkinleştirmeniz gerekir. Bu bağlantıyı kullanarak süreci tamamlayabilir ve Campaign Manager 360 API'yi otomatik olarak etkinleştirebilirsiniz.

Kimlik bilgisi oluşturma

Campaign Manager 360 API'ye yaptığınız tüm istekler yetkilendirilmelidir. Yetkilendirmeye dair kısa bir özet için uygulamanızı Google'da yetkilendirme ve tanımlama hakkında bilgi edinin.

Aşağıdaki talimatlar, yüklü uygulama akışıyla kullanılacak bir OAuth 2.0 istemci kimliği oluşturma sürecinde size yol gösterir. Hizmet hesabı akışıyla kullanılacak kimlik bilgilerinin oluşturulmasıyla ilgili talimatlar için Hizmet Hesapları kılavuzuna bakın.

  1. Google API Konsolu projesi yapılandırma adımlarını uygulayın.

  2. API Konsolu'nda Kimlik bilgileri sayfasını açın.
  3. KİMLİK BİLGİLERİ OLUŞTUR > OAuth istemci kimliği'ni tıklayın.

    1. Bu proje için daha önce bir OAuth izin ekranı yapılandırmadıysanız şimdi bunu yapmanız istenir. CONFIGURE CONSENT SCREEN'i (Kullanıcı rızası ekranını yapılandır) tıklayın.

    2. Kullanıcı türünü seçin ve OLUŞTUR'u tıklayın.

    3. İlk formu doldurun. Gerekirse bunu daha sonra düzenleyebilirsiniz. İşiniz bittiğinde Kaydet'i tıklayın.

    4. Devam etmek için Kimlik Bilgileri > KİMLİK BİLGİLERİ OLUŞTUR > OAuth istemci kimliği'ne geri dönün.

  4. Uygulama türü olarak Masaüstü uygulaması'nı seçin, uygulamaya bir ad verin ve Oluştur'u tıklayın.

İşlem tamamlandığında, JSON biçiminde indirebileceğiniz ve daha sonra kullanmak üzere kaydedebileceğiniz bir OAuth 2.0 istemci kimliği ve istemci gizli anahtarı gösterilir.

İstemci kitaplığı yükleme

Campaign Manager 360 API; HTTP ve JSON üzerine kurulu olduğundan herhangi bir standart HTTP istemcisi ona istek gönderebilir, yanıtları ayrıştırabilir.

Ancak Google API istemci kitaplıkları daha iyi dil entegrasyonu, daha yüksek güvenlik sağlamanın yanı sıra yetkilendirilmiş isteklerin yapılmasını da destekler. İstemci kitaplıkları çeşitli programlama dillerinde kullanılabilir. Bunları kullanarak HTTP isteklerini manuel olarak oluşturma ve yanıtları ayrıştırma zahmetinden kurtulabilirsiniz.

İstemci kitaplıklarını kullanmaya başlamak için geliştirmede kullandığınız programlama dilini seçin.

C#

En son .NET için Campaign Manager 360 API istemci kitaplığını yükleyin. Yüklemenizi yönetmek için NuGet'i kullanmanız önerilir.

NuGet Paket Yöneticisi Konsolu'nu açıp aşağıdaki komutu çalıştırın:

Install-Package Google.Apis.Dfareporting.v3_4

Daha Fazla Bilgi

Java

En son Java için Campaign Manager 360 API istemci kitaplığını yükleyin. Yüklemenizi yönetmek için Maven'ı kullanmanız önerilir.

pom.xml dosyanıza aşağıdaki bağımlılığı ekleyin:

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

Daha Fazla Bilgi

PHP

En son PHP için Campaign Manager 360 API istemci kitaplığını yükleyin. Kurulumunuzu yönetmek için Composer'ı kullanmanız önerilir.

Bir terminal açıp aşağıdaki komutu çalıştırın:

composer require google/apiclient

Kitaplığı zaten yüklediyseniz ve yalnızca en son sürüme güncellemek istiyorsanız:

composer update google/apiclient

Sisteminize bağlı olarak, bu komutların başına sudo eklemeniz gerekebilir.

Daha Fazla Bilgi

Python

En son Python için Campaign Manager 360 API istemci kitaplığını yükleyin. Yüklemenizi yönetmek için pip kullanmanız önerilir.

Bir terminal açıp aşağıdaki komutu çalıştırın:

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

Sisteminize bağlı olarak, bu komutların başına sudo eklemeniz gerekebilir.

Daha Fazla Bilgi

Ruby

En son Ruby için Campaign Manager 360 API istemci kitaplığını yükleyin. Yüklemenizi yönetmek için RubyGems'i kullanmanız önerilir.

Bir terminal açıp aşağıdaki komutu çalıştırın:

gem install google-api-client

Kitaplığı zaten yüklediyseniz ve yalnızca en son sürüme güncellemek istiyorsanız:

gem update -y google-api-client

Sisteminize bağlı olarak, bu komutların başına sudo eklemeniz gerekebilir.

Daha Fazla Bilgi

Desteklenen diğer dilleri İstemci Kitaplıkları sayfasında bulabilirsiniz.

İstekte bulunun

OAuth 2.0 kimlik bilgileri oluşturulduktan ve istemci kitaplığı yüklendikten sonra Campaign Manager 360 API'yi kullanmaya başlayabilirsiniz. Aşağıdaki hızlı başlangıç kılavuzunu inceleyerek istemcinizi nasıl yetkilendireceğinizi, yapılandıracağınızı ve ilk isteğinizi nasıl göndereceğinizi öğrenin.

C#

  1. İstemci gizli anahtarı dosyasını yükleyin ve yetkilendirme kimlik bilgileri oluşturun.

    Bu adımı ilk kez gerçekleştirdiğinizde tarayıcınızda bir yetkilendirme istemini kabul etmeniz istenir. Kabul etmeden önce Campaign Manager 360'a erişimi olan bir Google Hesabı ile giriş yaptığınızdan emin olun. Uygulamanız, o anda giriş yapılmış olan hesabın verilerine erişmek için yetkilendirilir.

    // 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. Yetkilendirilmiş bir Dfareporting istemcisi oluşturun.

    // 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. Bir işlem gerçekleştirin.

    // 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);
    }

Java

  1. İstemci gizli anahtarı dosyasını yükleyin ve yetkilendirme kimlik bilgileri oluşturun.

    Bu adımı ilk kez gerçekleştirdiğinizde tarayıcınızda bir yetkilendirme istemini kabul etmeniz istenir. Kabul etmeden önce Campaign Manager 360'a erişimi olan bir Google Hesabı ile giriş yaptığınızdan emin olun. Uygulamanız, o anda giriş yapılmış olan hesabın verilerine erişmek için yetkilendirilir.

    // 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. Yetkilendirilmiş bir Dfareporting istemcisi oluşturun.

    // 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. Bir işlem gerçekleştirin.

    // 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. İstemci gizli anahtarı dosyasını yükleyin ve yetkilendirme kimlik bilgileri oluşturun.

    Bu adımı ilk kez gerçekleştirdiğinizde tarayıcınızda bir yetkilendirme istemini kabul etmeniz istenir. Kabul etmeden önce Campaign Manager 360'a erişimi olan bir Google Hesabı ile giriş yaptığınızdan emin olun. Uygulamanız, o anda giriş yapılmış olan hesabın verilerine erişmek için yetkilendirilir.

    // 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. Yetkilendirilmiş bir Dfareporting istemcisi oluşturun.

    // Create a Dfareporting service object.
    $service = new Google_Service_Dfareporting($client);
  3. Bir işlem gerçekleştirin.

    // 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. İstemci gizli anahtarı dosyasını yükleyin ve yetkilendirme kimlik bilgileri oluşturun.

    Bu adımı ilk kez gerçekleştirdiğinizde tarayıcınızda bir yetkilendirme istemini kabul etmeniz istenir. Kabul etmeden önce Campaign Manager 360'a erişimi olan bir Google Hesabı ile giriş yaptığınızdan emin olun. Uygulamanız, o anda giriş yapılmış olan hesabın verilerine erişmek için yetkilendirilir.

    # 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. Yetkilendirilmiş bir Dfareporting istemcisi oluşturun.

    # Construct a service object via the discovery service.
    service = discovery.build('dfareporting', 'v4', http=http)
  3. Bir işlem gerçekleştirin.

    # 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. İstemci gizli anahtarı dosyasını yükleyin ve yetkilendirme kimlik bilgileri oluşturun.

    Bu adımı ilk kez gerçekleştirdiğinizde tarayıcınızda bir yetkilendirme istemini kabul etmeniz istenir. Kabul etmeden önce Campaign Manager 360'a erişimi olan bir Google Hesabı ile giriş yaptığınızdan emin olun. Uygulamanız, o anda giriş yapılmış olan hesabın verilerine erişmek için yetkilendirilir.

    # 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. Yetkilendirilmiş bir Dfareporting istemcisi oluşturun.

    # 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. Bir işlem gerçekleştirin.

    // 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);
    }

Daha fazla bilgi

API'nin sunduğu tüm hizmetler hakkında bilgi edinmek için API Referansı'nı ziyaret edin. Her yöntem ayrıntıları sayfasında, doğrudan tarayıcınızdan test istekleri göndermek için kullanabileceğiniz yerleştirilmiş bir API Explorer bulunur.

İleri düzey konuları ele alan ve sık gerçekleştirilen görevler için uçtan uca örnekler sunan diğer kılavuzlarımızı inceleyin.

Kod yazmaya başlamaya hazır olduğunuzda, ihtiyaçlarınıza uyacak şekilde değiştirilebilen ve genişletilebilen kapsamlı kod örnekleri koleksiyonumuza göz atabilirsiniz.