How To Update Text Promotion Condition Using Google Adwords Api Together With Php Customer Library?
There are 3 condition of text Ad:
1. ENABLED
2. DISABLED
3. PAUSED
If you lot delete AdGroupAd using 'REMOVE' operator thence you lot can't modify it anymore. If you lot endeavour to update it dorsum to 'ENABLED/PAUSED' you lot volition larn AdGroupAdError -> CANNOT_OPERATE_ON_DELETED_ADGROUPAD (Deleted ads may non live on modified).
If you lot desire to delete the AdGroupAd usage next purpose together with it uses 'REMOVE' Operator. This way that such Ad can't live on changed anymore. It volition never live on fully deleted, merely they volition ever be inwards your concern human relationship amongst the condition 'DISABLED'.
For example
Best Practice volition be: Instead of setting condition to 'DISABLED', you lot could fix it to 'PAUSED'. And if adding of novel AdGroupAd doesn't succeed, you lot could ever revert former AdGroupAd from 'PAUSED' to 'ACTIVE'.
For example
1. ENABLED
2. DISABLED
3. PAUSED
If you lot delete AdGroupAd using 'REMOVE' operator thence you lot can't modify it anymore. If you lot endeavour to update it dorsum to 'ENABLED/PAUSED' you lot volition larn AdGroupAdError -> CANNOT_OPERATE_ON_DELETED_ADGROUPAD (Deleted ads may non live on modified).
If you lot desire to delete the AdGroupAd usage next purpose together with it uses 'REMOVE' Operator. This way that such Ad can't live on changed anymore. It volition never live on fully deleted, merely they volition ever be inwards your concern human relationship amongst the condition 'DISABLED'.
For example
purpose DeleteAd($user, $adGroupId, $adId) { // Get the service, which loads the required classes. $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION); // Create base of operations course of didactics promotion to avoid setting type specific fields. $ad = novel Ad(); $ad->id = $adId; // Create promotion grouping ad. $adGroupAd = novel AdGroupAd(); $adGroupAd->adGroupId = $adGroupId; $adGroupAd->ad = $ad; // Create operation. $operation = novel AdGroupAdOperation(); $operation->operand = $adGroupAd; $operation->operator = 'REMOVE'; $operations = array($operation); // Make the mutate request. $result = $adGroupAdService->mutate($operations); // Display result. $adGroupAd = $result->value[0]; printf("Ad amongst ID '%s' was deleted.\n", $adGroupAd->ad->id); }If you lot desire to modify a text promotion that was created, thence you lot must usage 'SET' Operator. You tin update the condition of text promotion using next purpose together amongst 'SET' Operator.
Best Practice volition be: Instead of setting condition to 'DISABLED', you lot could fix it to 'PAUSED'. And if adding of novel AdGroupAd doesn't succeed, you lot could ever revert former AdGroupAd from 'PAUSED' to 'ACTIVE'.
For example
/** * Runs the example. * @param AdWordsUser $user the user to run the instance amongst * @param string $adGroupId the id of the promotion grouping containing the promotion * @param string $adId the ID of the promotion * @param string $status the status(ACTIVE, DELETED, PAUSED) of the promotion */ purpose UpdateAd($user, $adGroupId, $adId, $status) { // Get the service, which loads the required classes. $adGroupAdService = $user->GetService('AdGroupAdService', ADWORDS_VERSION); // Create promotion using an existing ID. Use the base of operations course of didactics Ad instead of TextAd to // avoid having to fix ad-specific fields. $ad = novel Ad(); $ad->id = $adId; // Create promotion grouping ad. $adGroupAd = novel AdGroupAd(); $adGroupAd->adGroupId = $adGroupId; $adGroupAd->ad = $ad; if($status == "DELETED") { $adGroupAd->status = 'DISABLED'; } if($status == "ACTIVE") { $adGroupAd->status = 'ENABLED'; } if($status == "PAUSED") { $adGroupAd->status = 'PAUSED'; } // Create operation. $operation = novel AdGroupAdOperation(); $operation->operand = $adGroupAd; $operation->operator = 'SET'; $operations = array($operation); // Make the mutate request. $result = $adGroupAdService->mutate($operations); // Display result. $adGroupAd = $result->value[0]; printf("Ad of type '%s' amongst ID '%s' has updated condition '%s'.\n", $adGroupAd->ad->AdType, $adGroupAd->ad->id, $adGroupAd->status); }Source: google-api-adwords-php library v201306 Sumber http://developer-paradize.blogspot.com
Comments
Post a Comment