On Tuesday, July 3, 2012 8:30:40 AM UTC-7, opalepatrick wrote:
>
> HI,
>
> be appreciated if someone can point me at a current link with php examples 
> showing how to update keyword status.
>


Hi.

Here is a function (in PHP) I use to perform basic updates to keywords... 
like CPC updates, activate, url, etc. 

    public function updateKeywords($ary) { 
        
        $user = new AdWordsUser(null, $this->username, $this->password, 
$this->developerToken);
        $user->SetDefaultServer($this->setServer);
        $user->LogAll();
        $user->SetClientId(null);

        $user->SetClientId($this->customerId);     

        // Get the service, which loads the required classes.
        $adGroupCriterionService = 
$user->GetService('AdGroupCriterionService', 'v201109');     

        // Create criterion using an existing ID. Use the base class 
Criterion
        // instead of Keyword to avoid having to set keyword-specific 
fields.
        $criterion = new Criterion();
        $criterion->id = $ary['criterionId'];

        // Create ad group criterion.
        $adGroupCriterion = new BiddableAdGroupCriterion();
        $adGroupCriterion->adGroupId = $this->adGroupId;
        $adGroupCriterion->criterion = new Criterion($ary['criterionId']);

        // Update destination URL.
        $adGroupCriterion->userStatus = 'ACTIVE';
        $adGroupCriterion->destinationUrl = $ary['destinationUrl'];
        
        $bids = new ManualCPCAdGroupCriterionBids();
        $bids->maxCpc = new Bid(new Money($ary['maxCpc']));
        $adGroupCriterion->bids = $bids;       

        // Create operation.
        $operation = new AdGroupCriterionOperation();
        $operation->operand = $adGroupCriterion;
        $operation->operator = 'SET';

        $operations = array($operation);

        // Make the mutate request.
        $result = $adGroupCriterionService->mutate($operations);

        // Display result.
        $adGroupCriterion = $result->value[0];
        printf("Keyword with id '%s' has updated destination URL '%s'.\n",
            $adGroupCriterion->criterion->id, 
$adGroupCriterion->destinationUrl);  
        
        return $adGroupCriterion; 
        
    }


-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to