使用AdWords API(PHP客户端库)管理Google Adwords Feed
如何使用AdWords API的php客户端库管理Google AdWords中的Feed? 我需要更改某些Feed项目中的数据,但我无法在php中找到适当的代码示例。 有人能帮助我吗? 提前致谢。
PHP代码本身的文档中提供了一些示例,以下是在给定Feed中添加feedItem的示例:https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201506/Extensions/ AddSitelinksUsingFeeds.php
在更新时,确保使用“SET”运算符而不是“ADD”。
基本上,你想要做的是以下几点:
foreach ($feedData as $data) {
$feedItemClass = new FeedItem();
$feedItemClass->attributeValues = [
// INT64, refer to (1) for more info
new FeedItemAttributeValue(1, (int)$data['id']),
// StringValues
new FeedItemAttributeValue(2, null, null, null, null, null, null, null, $data['urlLangs']),
// String
new FeedItemAttributeValue(3, null, null, null, $data['name']),
new FeedItemAttributeValue(4, null, null, null, $data['imageUrl']),
new FeedItemAttributeValue(5, null, null, null, $data['price']),
];
$feedItemClassOperation = new FeedItemOperation();
$feedItemClassOperation->operator = $operator;
$feedItemClassOperation->operand = $feedItemClass;
$allOperations[] = $feedItemClassOperation;
}
if (!empty($allOperations)) {
// Perform all operations at once
$feedItemService->mutate($allOperations);
}
(1):https://developers.google.com/adwords/api/docs/reference/v201506/FeedService.FeedAttribute
问候。
链接地址: http://www.djcxy.com/p/32373.html上一篇: Manage Google Adwords Feeds by using AdWords API (PHP Client Library)