如何使用AdWords Api的php客户端库管理Google AdWords中的Feed?我需要更改某些Feed项中的数据,但我无法在php中找到合适的代码示例。 有人能帮助我吗?提前谢谢。
答案 0 :(得分:0)
示例可以在PHP代码本身的文档中找到,这里是在给定的feed中添加feedItems的示例: 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
问候。