本文整理汇总了PHP中DfpUser::GetCreativeService方法的典型用法代码示例。如果您正苦于以下问题:PHP DfpUser::GetCreativeService方法的具体用法?PHP DfpUser::GetCreativeService怎么用?PHP DfpUser::GetCreativeService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DfpUser
的用法示例。
在下文中一共展示了DfpUser::GetCreativeService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dfp
public function dfp()
{
App::import("Vendor", "DFPUser", array("file" => "Google/Api/Ads/Dfp/Lib/DfpUser.php"));
$path = dirname(__FILE__) . '/../../..';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
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->GetCreativeService('v201104');
// Set the ID of the advertiser (company) that all creatives will be
// assigned to.
$advertiserId = (double) '1917';
// Create an array to store local image creative objects.
$imageCreatives = array();
for ($i = 0; $i < 5; $i++) {
$imageCreative = new ImageCreative();
$imageCreative->name = 'Image creative #' . $i;
$imageCreative->advertiserId = $advertiserId;
$imageCreative->destinationUrl = 'http://google.com';
$imageCreative->imageName = 'image.jpg';
$imageCreative->imageByteArray = MediaUtils::GetBase64Data('http://www.google.com/intl/en/adwords/' . 'select/images/samples/inline.jpg');
$imageCreative->size = new Size(300, 250);
$imageCreatives[] = $imageCreative;
}
// Create the image creatives on the server.
$imageCreatives = $creativeService->createCreatives($imageCreatives);
// Display results.
if (isset($imageCreatives)) {
foreach ($imageCreatives as $creative) {
// Use instanceof to determine what type of creative was returned.
if ($creative instanceof ImageCreative) {
print 'An image creative with ID "' . $creative->id . '", name "' . $creative->name . '", and size {' . $creative->size->width . ', ' . $creative->size->height . "} was created and\n" . ' can be previewed at: ' . $creative->previewUrl . "\n";
} else {
print 'A creative with ID "' . $creative->id . '", name "' . $creative->name . '", and type "' . $creative->CreativeType . "\" was created.\n";
}
}
} else {
print "No creatives created.\n";
}
} catch (Exception $e) {
print $e->getMessage() . "\n";
}
}
示例2: dirname
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->GetCreativeService('v201103');
// 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";
示例3: getCreative
public function getCreative($id)
{
$token = "creative_" . $id;
if (($c = Cache::read($token, "1day")) === false) {
$path = dirname(__FILE__) . '/dfp/src';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Google/Api/Ads/Dfp/Lib/DfpUser.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->GetCreativeService('v201108');
// Set the ID of the creative to get.
$creativeId = (double) $id;
// Get the creative.
$creative = $creativeService->getCreative($creativeId);
// Display results.
if (isset($creative)) {
$c = get_object_vars($creative);
foreach ($c as $k => $v) {
if (is_object($c[$k])) {
$c[$k] = get_object_vars($c[$k]);
}
}
Cache::write($token, $c, "1day");
} else {
}
} catch (Exception $e) {
return $e->getMessage();
}
}
return $c;
}