Closed petebowen closed 5 years ago
Could you please check this code example, Mattia?
Hi,
I just tried running the example and it executed succesfully.
Did you make any changes to the example file?
What is the type of the campaign you're passing as a parameter to the example?
I didn't make any changes to the example file.
I ran it from the command line: php examples/AdvancedOperations/CreateAndAttachSharedKeywordSet.php --customerId 1385038871 --campaignId 937462259
The campaign is a search campaign.
I've just run it again and grabbed the response.
Method Name: /google.ads.googleads.v1.services.SharedSetService/MutateSharedSets Host: googleads.googleapis.com Headers: { "x-goog-api-client": "gl-php\/7.3.4-1+ubuntu18.04.1+deb.sury.org+3 gapic\/ gax\/0.38.1 grpc\/1.21.3", "x-goog-request-params": "customer_id=1385038871", "developer-token": "REDACTED", "login-customer-id": "2382354678" } Request: {"customerId":"1385038871","operations":[{"create":{"type":"NEGATIVE_KEYWORDS","name":"API Negative keyword list - 5d020ecace6f6"}}]}
Method Name: /google.ads.googleads.v1.services.SharedCriterionService/MutateSharedCriteria Host: googleads.googleapis.com Headers: { "x-goog-api-client": "gl-php\/7.3.4-1+ubuntu18.04.1+deb.sury.org+3 gapic\/ gax\/0.38.1 grpc\/1.21.3", "x-goog-request-params": "customer_id=1385038871", "developer-token": "REDACTED", "login-customer-id": "2382354678" } Request: {"customerId":"1385038871","operations":[{"create":{"sharedSet":"customers/1385038871/sharedSets/2045979514"}},{"create":{"sharedSet":"customers/1385038871/sharedSets/2045979514"}}]}
Headers: { "request-id": "EPGH_qgWWgW_efStdncsbg", "date": "Thu, 13 Jun 2019 11:56:41 GMT", "alt-svc": "quic=\":443\"; ma=2592000; v=\"46,44,43,39\"" }
Status code: 3 Details: Request contains an invalid argument. Failure: {"errors":[{"errorCode":{"fieldError":"REQUIRED"},"message":"The required field was not present.","location":{"fieldPathElements":[{"fieldName":"operations","index":0},{"fieldName":"create"},{"fieldName":"criterion"}]}},{"errorCode":{"fieldError":"REQUIRED"},"message":"The required field was not present.","location":{"fieldPathElements":[{"fieldName":"operations","index":1},{"fieldName":"create"},{"fieldName":"criterion"}]}}]} Request with ID 'EPGH_qgWWgW_efStdncsbg' has failed. Google Ads failure details: field_error: The required field was not present. field_error: The required field was not present.
Best wishes.
Peter Bowen B.Tech. Eng. Civil
+447525757178 prbowen@gmail.com Skype: pete_bowen Lets chat. Schedule time here: https://calendly.com/prbowen
On Thu, 13 Jun 2019 at 12:30, Mattia Tommasone notifications@github.com wrote:
Hi,
I just tried running the example and it executed succesfully.
Did you make any changes to the example file?
What is the type of the campaign you're passing as a parameter to the example?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
The request you are sending is indeed lacking a required parameter.
As you can see at lines 138-146 of the example file, it creates a SharedCriterion object like this:
$sharedCriterion = new SharedCriterion([
'keyword' => new KeywordInfo([
'text' => new StringValue(['value' => $keyword]),
'match_type' => KeywordMatchType::BROAD
]),
'shared_set' => new StringValue(['value' => $sharedSetResourceName])
]);
However, your requests are sending only the sharedSet
property in the SharedCriterionOperation
Can you please
Thanks for the quick response.
I did a git clone a few hours ago so I presume I've got the latest and then a composer update.
Here's the section from the composer.json file "php": ">=7.1", "ext-grpc": "*", "google/gax": "^0.38.0", "google/protobuf": "^3.4.0", "google/common-protos": "^0.1.0", "ulrichsg/getopt-php": "^3.2.2", "monolog/monolog": "^1.23.0"
I haven't touched the example file. Here's a copy of the bits of code that should create the negative keywords from the example file
// Creates shared set criteria. $sharedCriterionOperations = []; // Keywords to create a shared set of. $keywords = ['mars cruise', 'mars hotels']; foreach ($keywords as $keyword) { $sharedCriterion = new SharedCriterion([ 'keyword' => new KeywordInfo([ 'text' => new StringValue(['value' => $keyword]), 'match_type' => KeywordMatchType::BROAD ]), 'shared_set' => new StringValue( ['value' => $sharedSetResourceName] ) ]);
$sharedCriterionOperation = new SharedCriterionOperation();
$sharedCriterionOperation->setCreate($sharedCriterion);
$sharedCriterionOperations[] = $sharedCriterionOperation;
}
$sharedCriterionServiceClient =
$googleAdsClient->getSharedCriterionServiceClient(); $response = $sharedCriterionServiceClient->mutateSharedCriteria( $customerId, $sharedCriterionOperations );
Best wishes.
Peter Bowen B.Tech. Eng. Civil
+447525757178 prbowen@gmail.com Skype: pete_bowen Lets chat. Schedule time here: https://calendly.com/prbowen
On Thu, 13 Jun 2019 at 14:22, Mattia Tommasone notifications@github.com wrote:
The request you are sending is indeed lacking a required parameter.
As you can see at lines 138-146 of the example file, it creates a SharedCriterion object like this:
$sharedCriterion = new SharedCriterion([ 'keyword' => new KeywordInfo([ 'text' => new StringValue(['value' => $keyword]), 'match_type' => KeywordMatchType::BROAD ]), 'shared_set' => new StringValue(['value' => $sharedSetResourceName])]);
However, your requests are sending only the sharedSet property in the SharedCriterionOperation
Can you please
- Confirm that the example you are running is constructing the SharedCriterion object the same way I pasted here
- Confirm which version of the client library you are using
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-php/issues/119?email_source=notifications&email_token=ABBDRCE7M23BALAAQWCUPDDP2JC25A5CNFSM4HXWY562YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXTVPPI#issuecomment-501700541, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBDRCHWLAMO2RDP4Q2OQVLP2JC25ANCNFSM4HXWY56Q .
I've found a clue to what the problem might be in the solution to this: https://github.com/googleads/google-ads-php/issues/94
I had previously installed protobuf (pecl install protobuf) and added the extension=protobuf.so to php.ini from the instructions linked on the readme.md file to this page https://grpc.io/docs/quickstart/php/
When I don't install this version of protobuf and rely on composer to install it I get an error warning but the example works as expected. Here's the error
PHP Warning: PHP Startup: Unable to load dynamic library 'protobuf.so' (tried: /usr/lib/php/20180731/protobuf.so (/usr/lib/php/20180731/protobuf.so: cannot open shared object file: No such file or directory), /usr/lib/php/20180731/protobuf.so.so (/usr/lib/php/20180731/protobuf.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Does this shed light on the problem?
Yes, definitely, thanks for commenting on this.
Do depend on the composer dependency to install the protobuf extension, then, since it makes the example work as intended.
To remove the warning, you can comment out the extension line in your php.ini file.
Mattia,
Pls file a bug for the grpc team and ping me the link. Our code examples and libraries should not behave differently based on whether the user enabled the protobuf extension.
Tx
On Tue, Jun 18, 2019 at 3:54 PM Mattia Tommasone notifications@github.com wrote:
Yes, definitely, thanks for commenting on this.
Do depend on the composer dependency to install the protobuf extension, then, since it makes the example work as intended.
To remove the warning, you can comment out the extension line in your php.ini file.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-php/issues/119?email_source=notifications&email_token=ABCOJCGXFGBLB5JGW5G2TZDP3E4N5A5CNFSM4HXWY562YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX7YWDI#issuecomment-503286541, or mute the thread https://github.com/notifications/unsubscribe-auth/ABCOJCCDBPXOCTIWOT6I553P3E4N5ANCNFSM4HXWY56Q .
-- Anash P. Oommen | Developer Programs Engineer | anash@google.com | +1-650-440-2854
Referring to https://github.com/googleads/google-ads-php/blob/master/examples/AdvancedOperations/CreateAndAttachSharedKeywordSet.php
The shared negative keyword list is created ok (line 122) but I get an error when trying to add negative keywords to the list. (line 154)
The error reads '40yJVrZ1EcK0_2-jhYZy4w' has failed. Google Ads failure details: field_error: The required field was not present.'