BatchJobService: how to PHP

113 views
Skip to first unread message

giorgio...@gmail.com

unread,
Mar 3, 2016, 8:43:35 AM3/3/16
to AdWords API Forum
Hi all,
I was reading the BatchJobService guide on google adwords but I didnt understand how I can use it for massive operations in PHP.
For example:

  $operations[] = new CampaignCriterionOperation($negativeCriterion, 'ADD');
  $result = $campaignCriterionService->mutate($operations);

That code will give me a result of one operation, like adding one keyword but, if I want to add 500 keywords it seems not legit to do 500 operations, one for each kw, but it should be so faster and better doing just one operation for 500kws.
Anyone can help me doing that with BatchJobService?
Thanks a lot!

Umesh Dengale

unread,
Mar 3, 2016, 2:46:56 PM3/3/16
to AdWords API Forum
Hello,

You could use the BatchJobService to add keywords in bulk. The BatchJobService allows asynchronous processing. You could upload 500 keywords in one request. Please check our batch processing guidebest practices guide and AddKeywordsInBulk PHP example code from the client library.

Thanks,
Umesh, AdWords API Team.

giorgio...@gmail.com

unread,
Mar 7, 2016, 12:09:20 PM3/7/16
to AdWords API Forum
Hi, thanks for the answer.
I've already read all your guides but still not understand how to use BatchJobService.
I mean, im easily trying to add 100negative keywords per campaign and, of course, im using one result foreach kw. If I want to add those 100kws in a one result I have to add 400rows of code using batchjobservice?
As I said just let me know as an example how to modify these rows of code using batchjobservice:

  $operations[] = new CampaignCriterionOperation($negativeCriterion, 'ADD');
  $result = $campaignCriterionService->mutate($operations);

Umesh Dengale

unread,
Mar 7, 2016, 5:27:29 PM3/7/16
to AdWords API Forum
Hello,

Adding each keyword will consider as one operation and BatchJobService.mutate operation (with ADD operator) takes array of BatchJobOperation (using loop you could add multiple CampaignCriterionOperation as described in the AddKeywordsInBulk example) and return type will be BatchJobReturnValue(return values from the BatchJobService). As per the rate sheet guide each mutate operation count as one operation. 

To update the negative keywords at campaign level in bulk using BatchJobService.mutate operation, you could use CampaignCriterionOperation.operand as NegativeCampaignCriterion and the operator as SET. We don't have example code for update keywords using BatchJobService. However, you could refer UpdateKeyword(which uses CampaignCriterionService.mutate operation) PHP example code from the client library and use similar approach for CampaignCriterionOperation for the BatchJobService to update negative keywords in bulk. 
Reply all
Reply to author
Forward
0 new messages