Пример #1
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            String campaignName    = _T("INSERT_CAMPAIGN_NAME_HERE");
            String landingPageName = _T("INSERT_LANDING_PAGE_NAME_HERE");
            String url             = _T("INSERT_LANDING_PAGE_URL_HERE");

            // Create the campaign structure.
            Campaign campaign = new Campaign();

            campaign.Name         = campaignName;
            campaign.AdvertiserId = advertiserId;
            campaign.Archived     = false;

            // Set the campaign start date. This example uses today's date.
            campaign.StartDate =
                DfaReportingDateConverterUtil.convertToDateString(DateTime.Now);

            // Set the campaign end date. This example uses one month from today's date.
            campaign.EndDate =
                DfaReportingDateConverterUtil.convertToDateString(DateTime.Now.AddMonths(1));

            // Insert the campaign.
            Campaign result =
                service.Campaigns.Insert(campaign, profileId, landingPageName, url).Execute();

            // Display the new campaign ID.
            Console.WriteLine("Campaign with ID {0} was created.", result.Id);
        }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            // Limit the fields returned.
            String fields = "nextPageToken,items(id,value)";

            // Construct the dimension value request.
            DimensionValueRequest request = new DimensionValueRequest();

            request.DimensionName = "dfa:advertiser";

            // Set the date range from 1 year ago until today.
            request.StartDate =
                DfaReportingDateConverterUtil.convertToDateString(DateTime.Now.AddYears(-1));
            request.EndDate =
                DfaReportingDateConverterUtil.convertToDateString(DateTime.Now);

            DimensionValueList values;
            String             nextPageToken = null;

            do
            {
                // Create and execute the dimension value query request.
                DimensionValuesResource.QueryRequest query =
                    service.DimensionValues.Query(request, profileId);
                query.Fields    = fields;
                query.PageToken = nextPageToken;
                values          = query.Execute();

                foreach (DimensionValue value in values.Items)
                {
                    Console.WriteLine("Dimension value with ID {0} and value \"{1}\" was found.",
                                      value.Id, value.Value);
                }

                // Update the next page token.
                nextPageToken = values.NextPageToken;
            } while (values.Items.Any() && !String.IsNullOrEmpty(nextPageToken));
        }
Пример #3
0
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="service">An initialized Dfa Reporting service object
        /// </param>
        public override void Run(DfareportingService service)
        {
            long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE"));
            long profileId    = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE"));

            String campaignName = _T("INSERT_CAMPAIGN_NAME_HERE");

            // [START create_campaign] MOE:strip_line
            // Locate an advertiser landing page to use as a default.
            LandingPage defaultLandingPage = getAdvertiserLandingPage(service, profileId, advertiserId);

            // Create the campaign structure.
            Campaign campaign = new Campaign();

            campaign.Name                 = campaignName;
            campaign.AdvertiserId         = advertiserId;
            campaign.Archived             = false;
            campaign.DefaultLandingPageId = defaultLandingPage.Id;

            // Set the campaign start date. This example uses today's date.
            campaign.StartDate =
                DfaReportingDateConverterUtil.convertToDateString(DateTime.Now);

            // Set the campaign end date. This example uses one month from today's date.
            campaign.EndDate =
                DfaReportingDateConverterUtil.convertToDateString(DateTime.Now.AddMonths(1));
            // [END create_campaign] MOE:strip_line

            // [START insert_campaign] MOE:strip_line
            // Insert the campaign.
            Campaign result = service.Campaigns.Insert(campaign, profileId).Execute();

            // [END insert_campaign] MOE:strip_line

            // Display the new campaign ID.
            Console.WriteLine("Campaign with ID {0} was created.", result.Id);
        }