-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V16 Library expecting instances from V14 Classes #1017
Comments
Full error shown below
|
Could you please share the whole code? |
<?php
namespace App\Libraries;
use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder;
use Google\Ads\GoogleAds\Lib\V16\GoogleAdsClientBuilder;
use Google\Ads\GoogleAds\V16\Services\Client\GoogleAdsServiceClient;
use Google\Ads\GoogleAds\V16\Services\SearchGoogleAdsRequest;
class GoogleAdwordsClient
{
public $config;
public GoogleAdsServiceClient $serviceClient;
public $ADWORDS_MANAGER_ACCOUNT_ID = "1234567";
public function __construct()
{
$rootDirectory = base_path();
$this->config = $rootDirectory . '/secure/google_ads_php.ini';
}
public function getHeierarchy()
{
// Generate a refreshable OAuth2 credential for authentication.
$oAuth2Credential = (new OAuth2TokenBuilder())->fromFile($this->config)->build();
$googleAdsClient = (new GoogleAdsClientBuilder())
->fromFile($this->config)
->withOAuth2Credential($oAuth2Credential)
->withLoginCustomerId($this->ADWORDS_MANAGER_ACCOUNT_ID)
->usingGapicV2Source(true)
->build();
// Creates the Google Ads Service client.
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
// Creates a query that retrieves all child accounts of the manager specified in search
// calls below.
$query = 'SELECT customer_client.client_customer, customer_client.level,'
. ' customer_client.manager, customer_client.descriptive_name,'
. ' customer_client.currency_code, customer_client.time_zone,'
. ' customer_client.id FROM customer_client WHERE customer_client.level <= 1';
$result = $googleAdsServiceClient->search(SearchGoogleAdsRequest::build($this->ADWORDS_MANAGER_ACCOUNT_ID, $query));
dd($result);
}
} |
Could you try running GetCampaigns? Your code above looks okay to me. It shouldn't rely on any V14 classes. Actually, most of the classes you're using (e.g., |
Running the code just results in this error. Not sure if this gives anymore insight though. at vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:979
975▕ if (is_string($value) && trim($value) !== $value) {
976▕ throw new GPBDecodeException(
977▕ "Invalid data type for int64 field");
978▕ }
➜ 979▕ if (bccomp($value, "9223372036854775807") > 0) {
980▕ throw new GPBDecodeException(
981▕ "Int64 too large");
982▕ }
983▕ if (bccomp($value, "-9223372036854775808") < 0) {
|
What code did you run? And what's the error message? |
Sorry my copy left out the error message portion, this was runningt he getHeirarchy method on the class I posted. Error
Call to undefined function Google\Protobuf\Internal\bccomp()
at vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:979
975▕ if (is_string($value) && trim($value) !== $value) {
976▕ throw new GPBDecodeException(
977▕ "Invalid data type for int64 field");
978▕ }
➜ 979▕ if (bccomp($value, "9223372036854775807") > 0) {
980▕ throw new GPBDecodeException(
981▕ "Int64 too large");
982▕ }
983▕ if (bccomp($value, "-9223372036854775808") < 0) { |
Usually, it shouldn't trigger that part. It looks like you need to install So, do you still get the error about v14 like you mentioned above? |
Added in the bcmath extension which resolves the runtime error but still getting the typing errors. |
What typing errors do you mean? |
The main error is this. II wasnt sure if the bcmath package was related because it had not yet been installed but now that its working that isnt the case and I am still getting the type errors.
|
So, did you try what I asked previously. What did you get as a result? |
Closing due to inactivity. Feel free to reopen this if you still need help. |
[DO NOT INCLUDE ANY PERSONAL OR SENSITIVE DATA - MAKE SURE TO REDACT CONTENT WHEN NECESSARY]
Your client library and Google Ads API versions:
v22.1.0
V16
Your environment:
Description of the bug:
When using only the V16 version of the library the an error is thrown requesting an instance to be passed in from the V14 library
Steps to reproduce:
Code mostly pulled from the examples in repo
Despite all imports for the above code using V16 library, the search method on the
$googleAdsServiceClient
complains that we are not passing in aSearchGoogleAdsRequest
from the V14 library, then changing to import to the v14 library it then complains as it expects two strings passed instead.Expected behavior:
Expect the method to accept the instance of SearchGoogleAdsRequest from the v16 library as shown in example code provided from the Google repo
Request/Response Logs:
Anything else we should know about your project / environment:
The text was updated successfully, but these errors were encountered: