Here is a snippet of my php method for better understanding:
public function addSitelink(AdWordsUser $user, $data)
{
$user->LogAll();
$result = array('success' => true);
$feedItemService = $user->GetService('FeedItemService',
ADWORDS_VERSION);
$startDate = DateTime::createFromFormat('Y-m-d H:i:s',
$data['start_time']);
$endDate = DateTime::createFromFormat('Y-m-d H:i:s',
$data['end_time']);
// Create new feed item
$feedItem = new FeedItem();
/*$feedItem->feedItemId = !empty($data['external_id']) ?
$data['external_id'] : null;*/
$feedItem->feedId = intval($data['external_feed_id']);
$feedItem->status = $data['status'];
$feedItem->startTime = $startDate->format('Ymd His');
$feedItem->endTime = $endDate->format('Ymd His');
$feedItem->devicePreference = $data['device_preference'];
$itemAttributeValues = array();
// Assign Attributes
foreach ($data['attributes'] as $attribute) {
$itemAttributeValue = new FeedItemAttributeValue();
$itemAttributeValue->stringValue = $attribute['value'];
$itemAttributeValue->feedAttributeId =
$attribute['external_feed_attribute_id'];
$itemAttributeValues[] = $itemAttributeValue;
}
$feedItem->attributeValues = $itemAttributeValues;
$itemOperations[] = new FeedItemOperation($feedItem, 'ADD');
try {
$response = $feedItemService->mutate($itemOperations);
$result['response'] = $response->value[0];
} catch (Exception $e) {
// process error
$result['success'] = false;
$result['errors'][] = $this->getErrorMessage($e);
return $result;
}
.....
.....
// Do some more stuff
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.