My favorites | Sign in
Google
             
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2009, Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/** This code sample creates a new campaign with ad scheduling. */

using SampleCode.com.google.sandbox.v13.CampaignService;
using DayOfWeek = SampleCode.com.google.sandbox.v13.CampaignService.DayOfWeek;

using System;

namespace SampleCode.v13 {
public class AddCampaign {
// Provide AdWords login information.
private static String email = "INSERT_LOGIN_EMAIL_HERE";
private static String password = "INSERT_PASSWORD_HERE";
private static String clientEmail = "INSERT_CLIENT_LOGIN_EMAIL_HERE";
private static String useragent =
"INSERT_COMPANY_NAME: AdWords API DotNet Sample Code";
private static String developerToken = "INSERT_DEVELOPER_TOKEN_HERE";
private static String applicationToken =
"INSERT_APPLICATION_TOKEN_HERE";

public static void Main() {
try {
// Set up service connection.
CampaignService service = new CampaignService();

// Define SOAP headers.
service.emailValue = new email();
service.emailValue.Text = new String[] {email};
service.passwordValue = new password();
service.passwordValue.Text = new String[] {password};
service.clientEmailValue = new clientEmail();
service.clientEmailValue.Text = new String[] {clientEmail};
service.useragentValue = new useragent();
service.useragentValue.Text = new String[] {useragent};
service.developerTokenValue = new developerToken();
service.developerTokenValue.Text = new String[] {developerToken};
service.applicationTokenValue = new applicationToken();
service.applicationTokenValue.Text = new String[] {applicationToken};

// Create new campaign structure with ad scheduling set to show ads on
// Monday, Wednesday, and Friday from 8:00am to 5:00pm. Each bid is
// multiplied by 1.0.

SchedulingInterval intervalMonday = new SchedulingInterval();
intervalMonday.day = DayOfWeek.Monday;
intervalMonday.endHour = 17;
intervalMonday.endMinute = 0;
intervalMonday.multiplier = 1.0;
intervalMonday.startHour = 8;
intervalMonday.startMinute = 0;
SchedulingInterval intervalWednesday = new SchedulingInterval();
intervalWednesday.day = DayOfWeek.Wednesday;
intervalWednesday.endHour = 17;
intervalWednesday.endMinute = 0;
intervalWednesday.multiplier = 1.0;
intervalWednesday.startHour = 8;
intervalWednesday.startMinute = 0;
SchedulingInterval intervalFriday = new SchedulingInterval();
intervalFriday.day = DayOfWeek.Friday;
intervalFriday.endHour = 17;
intervalFriday.endMinute = 0;
intervalFriday.multiplier = 1.0;
intervalFriday.startHour = 8;
intervalFriday.startMinute = 0;

AdSchedule schedule = new AdSchedule();
schedule.intervals = new SchedulingInterval[] {
intervalMonday, intervalWednesday, intervalFriday};
schedule.status = AdScheduleStatus.Enabled;

// Create new campaign structure.
Campaign campaign = new Campaign();
campaign.name = "Sample Campaign US";
campaign.budgetAmount = 100000L;
campaign.budgetAmountSpecified = true;
campaign.budgetPeriod = BudgetPeriod.Daily;
campaign.budgetPeriodSpecified = true;
GeoTarget geoTargeting = new GeoTarget();
CountryTargets countryTargets = new CountryTargets();
countryTargets.countries = new String[] {"US"};
geoTargeting.countryTargets = countryTargets;
campaign.geoTargeting = geoTargeting;
campaign.languageTargeting = new String[] {"en"};
campaign.schedule = schedule;

// Add campaign.
campaign = service.addCampaign(campaign);

// Display new campaign.
Console.WriteLine("New campaign with name \"" + campaign.name
+ "\" and id \"" + campaign.id + "\" was created.");
} catch (Exception e) {
Console.WriteLine(e);
}
}
}
}
Show details Hide details

Change log

r25 by api.anash on Mar 05, 2009   Diff
Removed support for v12, made v13 the
default version (Merge with r23)
Go to: 
Project members, sign in to write a code review

Older revisions

r24 by api.anash on Mar 05, 2009   Diff
Rolling back to Revision 22
r23 by api.anash on Mar 05, 2009   Diff
Removed support for v12, made v13 the
default version.
r9 by api.anash on Nov 21, 2008   Diff
Old v12 files, for the documentation
to work.
All revisions of this file

File info

Size: 4651 bytes, 110 lines