My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
<?php
/**
* This example gets all image creatives. The statement
* retrieves up to the maximum page size limit of 500. To create an image
* creative, run CreateCreativesExample.php.
*
* Tags: CreativeService
*
* PHP version 5
*
* Copyright 2011, 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.
*
* @package GoogleApiAdsDfp
* @subpackage v201111
* @category WebServices
* @copyright 2011, Google Inc. All Rights Reserved.
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License,
* Version 2.0
* @author Adam Rogal <api.arogal@gmail.com>
* @author Eric Koleda <api.ekoleda@gmail.com>
*/

error_reporting(E_STRICT | E_ALL);

// You can set the include path to src directory or reference
// DfpUser.php directly via require_once.
// $path = '/path/to/dfp_api_php_lib/src';
$path = dirname(__FILE__) . '/../../../src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.php';
require_once 'Google/Api/Ads/Common/Util/MapUtils.php';

try {
// Get DfpUser from credentials in "../auth.ini"
// relative to the DfpUser.php file's directory.
$user = new DfpUser();

// Log SOAP XML request and response.
$user->LogDefaults();

// Get the CreativeService.
$creativeService = $user->GetService('CreativeService', 'v201111');

// Create bind variables.
$vars = MapUtils::GetMapEntries(
array('creativeType' => new TextValue('ImageCreative')));

// Create a statement to only select image creatives.
$filterStatement =
new Statement("WHERE creativeType = :creativeType LIMIT 500", $vars);

// Get creatives by statement.
$page = $creativeService->getCreativesByStatement($filterStatement);

// Display results.
if (isset($page->results)) {
$i = $page->startIndex;
foreach ($page->results as $creative) {
print $i . ') Creative with ID "' . $creative->id
. '", name "' . $creative->name
. '", and type "' . $creative->CreativeType
. "\" was found.\n";
$i++;
}
}

print 'Number of results found: ' . $page->totalResultSetSize . "\n";
} catch (Exception $e) {
print $e->getMessage() . "\n";
}

Change log

r120 by eric.kol...@google.com on Nov 30, 2011   Diff
Added examples for v201111.
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 2741 bytes, 83 lines
Powered by Google Project Hosting