Exemple #1
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">Unused</param>
        public override void Run(DfareportingService service)
        {
            string pathToJsonFile = _T("ENTER_PATH_TO_JSON_FILE_HERE");

            // Build user account credential.
            UserCredential credential =
                getUserAccountCredential(pathToJsonFile, new FileDataStore(DataStorePath, true));

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

            // 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);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">Unused</param>
        public override void Run(DfareportingService service)
        {
            string pathToJsonFile = _T("ENTER_PATH_TO_JSON_FILE_HERE");

            // An optional Google account email to impersonate. Only applicable to service accounts which
            // have enabled domain-wide delegation and wish to make API requests on behalf of an account
            // within their domain. Setting this field will not allow you to impersonate a user from a
            // domain you don't own (e.g., gmail.com).
            string emailToImpersonate = _T("");

            // Build service account credential.
            ServiceAccountCredential credential =
                getServiceAccountCredential(pathToJsonFile, emailToImpersonate);

            // 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# service account sample"
            }
                );

            // 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);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            // 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(profile.UserName);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            // 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("User profile with ID {0} and name \"{1}\" was found for account {2}.",
                                  profile.ProfileId, profile.UserName, profile.AccountId);
            }
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">Unused</param>
        public override void Run(DfareportingService service)
        {
            string emailToImpersonate = _T("ENTER_EMAIL_TO_IMPERSONATE_HERE");
            string pathToJsonFile     = _T("ENTER_PATH_TO_JSON_FILE_HERE");

            // Create the Dfareporting service using service account credentials.
            service = new DfareportingService(new BaseClientService.Initializer {
                HttpClientInitializer =
                    getServiceAccountCredential(pathToJsonFile, emailToImpersonate),
                ApplicationName = "DFA/DCM Reporting and Trafficking API Samples"
            });

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