-
Notifications
You must be signed in to change notification settings - Fork 0
/
updatecamp.php
51 lines (35 loc) · 1.17 KB
/
updatecamp.php
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
<?php
require_once 'lib/Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
$adwords_version ="v201509";
$id = $_GET['id'];
$campaignId = $id;
function UpdateCampaign(AdWordsUser $user, $campaignId) {
// Get the service, which loads the required classes.
$campaignService = $user->GetService('CampaignService', $adwords_version);
// Create campaign using an existing ID.
$campaign = new Campaign();
$campaign->id = $campaignId;
$campaign->status = 'PAUSED';
// Create operation.
$operation = new CampaignOperation();
$operation->operand = $campaign;
$operation->operator = 'SET';
$operations = array($operation);
// Make the mutate request.
$result = $campaignService->mutate($operations);
// Display result.
$campaign = $result->value[0];
echo "Campaign with ID '%s' was paused.\n", $campaign->id;
}
try {
// Get AdWordsUser from credentials in "../auth.ini"
// relative to the AdWordsUser.php file's directory.
$user = new AdWordsUser();
// Log every SOAP XML request and response.
$user->LogAll();
// Run the example.
UpdateCampaign($user, $campaignId);
} catch (Exception $e) {
printf("An error has occurred: %s\n", $e->getMessage());
}
?>