本文整理汇总了PHP中AdWordsSoapClient::mutate方法的典型用法代码示例。如果您正苦于以下问题:PHP AdWordsSoapClient::mutate方法的具体用法?PHP AdWordsSoapClient::mutate怎么用?PHP AdWordsSoapClient::mutate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdWordsSoapClient
的用法示例。
在下文中一共展示了AdWordsSoapClient::mutate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateFeedMappings
/**
* Updates the FeedMapping for the Feed to include AttributeFieldMappings for
* the new line 1 and line 2 FeedAttributes.
*
* @param AdWordsSoapClient $feedMappingService the feed mapping service
* @param string $feedId the feedId to attach the items to.
* @param FeedAttribute $line1Attribute the FeedAttribute for line 1 description
* @param FeedAttribute $line2Attribute the FeedAttribute for line 2 description
*/
function UpdateFeedMappings(AdWordsSoapClient $feedMappingService, $feedId, $line1Attribute, $line2Attribute)
{
$selector = new Selector();
$selector->fields = array('FeedId', 'FeedMappingId', 'PlaceholderType', 'AttributeFieldMappings');
$selector->predicates = array();
$selector->predicates[0] = new Predicate('FeedId', 'EQUALS', array($feedId));
$selector->predicates[1] = new Predicate('Status', 'EQUALS', array('ACTIVE'));
$feedMapping = $feedMappingService->get($selector)->entries[0];
// Remove the existing mapping (FeedMapping is immutable).
$feedMapping = $feedMappingService->mutate(array(new FeedMappingOperation($feedMapping, 'REMOVE')))->value[0];
// Create line 1 and line 2 attribute field mappings.
$line1FieldMapping = new AttributeFieldMapping();
$line1FieldMapping->feedAttributeId = $line1Attribute->id;
$line1FieldMapping->fieldId = PLACEHOLDER_FIELD_LINE_1_TEXT;
$line2FieldMapping = new AttributeFieldMapping();
$line2FieldMapping->feedAttributeId = $line2Attribute->id;
$line2FieldMapping->fieldId = PLACEHOLDER_FIELD_LINE_2_TEXT;
// Combine the existing field mappings with the new mappings.
$feedMapping->attributeFieldMappings = array_merge($feedMapping->attributeFieldMappings, array($line1FieldMapping, $line2FieldMapping));
$response = $feedMappingService->mutate(array(new FeedMappingOperation($feedMapping, 'ADD')));
$mutatedMapping = $response->value[0];
printf("Updated field mappings for feedId %d and feedMappingId %d to:\n", $mutatedMapping->feedId, $mutatedMapping->feedMappingId);
foreach ($mutatedMapping->attributeFieldMappings as $fieldMapping) {
printf(" feedAttributeId %s --> fieldId %s\n", $fieldMapping->feedAttributeId, $fieldMapping->fieldId);
}
}