Posts tagged with php

I want to use the Google Ads API to access Google Ads reports. As a preliminary step, we want to use the GoogleCustomerServiceClient to retrieve customer information.

$MMC_ID = <My MMC 10 digits number>; $credentialsIniPath = app_path('resources/credentials/google/google_ads_php.ini'); $oAuth2Credential = (new OAuth2TokenBuilder())     ->fromFile($credentialsIniPath)     ->build(); $googleAdsClient = (new GoogleAdsClientBuilder())     ->fromFile($credentialsIniPath)     ->withOAuth2Credential($oAuth2Credential)     ->build(); $customerServiceClient = $googleAdsClient->getCustomerServiceClient(); try {     $customer = $customerServiceClient->getCustomer(ResourceNames::forCustomer($MMC_ID)); } catch(GoogleAdsException $e) {     $this->error($e->getMessage()); } 

But it returns an error

Fault ------- Status code: 7 Details: The caller does not have permission Failure: {"errors":[{"errorCode":{"authorizationError":"DEVELOPER_TOKEN_NOT_APPROVED"},"message":"The developer token is not approved. Non-approved developer tokens can only be used with test accounts."}]} 

The account Oauth2 login that created MMC, MMC is a test account. In google_ads_php.ini, clientId, clientSecret, refreshToken, and developerToken are already filled in. The refreshToken has just been generated.

What should I check for in this one?

Thanks.

I am working with the GEO_PERFORMANCE_REPORT in order to fetch data related to the account locations. More specifically, the report I am working with is the User Locations Report, which can be found directly on the AdWords UI.

But I found out that there are some notorious differences for the data obtained via the AdWords API and the data shown via the AdWords UI, and the issues happen specifically with the aforementioned report, but also with the “Geographic Report”. I have applied the corresponding filters for the query, just as it's stated on the official documentation (1 and 2), but even with that, the data differs a lot between both sources.

The query I am constructing ends up being the following one:

Google\AdsApi\AdWords\Query\v201809\ReportQuery {#7426   -awqlString: "SELECT CampaignId, LocationType, Clicks, Impressions, CityCriteriaId, MostSpecificCriteriaId, CountryCriteriaId FROM GEO_PERFORMANCE_REPORT WHERE LocationType = 'LOCATION_OF_PRESENCE' AND IsTargetingLocation IN ['TRUE', 'FALSE'] DURING 20200401,20200430" } 

And the results I am getting (after sorting them by the Clicks metric) are the following: https://www.dropbox.com/s/6xpme91ig6wu1oy/Screenshot%202020-05-13%2018.18.43.png?dl=0. But on the AdWords UI I get the following: https://www.dropbox.com/s/cgtyglbs87lkb1p/Screenshot%202020-05-13%2018.20.20.png?dl=0.

I can see that there are similar issues open at the AdWords forum (1 and 2), but none of them seem fully solved.

Finally, based in the https://developers.google.com/adwords/api/docs/appendix/geotargeting documentation and in some other tests I did by using the MostSpecificCriteriaId, I have the theory that this could be an issue with the zipcodes mapping on the API.

Do you know what is the reason of the discrepancy for the click counts (and also for the impression counts) between both sources of these report?. Help will be appreciated.

I want to filter information inside the foreach and to return as result only some of them.

This is the code :

    $keywords = "";     $avgmonthly = "";     $compet ="";     foreach ($response->getResults() as $result) {         $avgmonthly = $result->getKeywordIdeaMetrics()->getAvgMonthlySearches()->getValue();         $compet = $result->getKeywordIdeaMetrics()->getCompetition();         $log = $this->getLogger();         $log->err($response->serializeToJsonString());         if ($avgmonthlysearch > 10 && $competition== 4) {             $keywords .= $result->getText()->getValue() . ",";         }     }         return $keywords; 

in my log i see this results:

{"results":[{"text":"world","keywordIdeaMetrics":  {"avgMonthlySearches":"140","competition":"HIGH"}},  {"text":"today ","keywordIdeaMetrics":{"avgMonthlySearches":"10","competition":"HIGH"{"text":"office","keywordIdeaMetrics":{"avgMonthlySearches":"5","competition":"LOW"}} 

when i try to call this function i get this error : Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function getAvgMonthlySearches() on null

I'm using google ads to generate keywords ,

I'm not sure if i did follow the right instructions.

I created at first a manager account https://developers.google.com/adwords/api/docs/guides/accounts-overview#test_accounts then i apply for test account ( but in my status test account is close) even manager :( and i don't know why.

Teams from google ads said that in their system they are open ...however

When i test my app with developer token and outh2 : i got this message

ApiException was thrown with message '{     "message": "The caller does not have permission",     "code": 7,     "status": "PERMISSION_DENIED",     "details": [         {             "@type": 0,             "data": "type.googleapis.com\/google.ads.googleads.v3.errors.GoogleAdsFailure"         },         {             "@type": 0,             "data": [                 {                     "errorCode": {                         "authorizationError": "CUSTOMER_NOT_ENABLED"                     },                     "message": "The customer can't be used because it isn't enabled."                 }             ]         }     ] }' 

Do you have experience with google ads api ?

I want to return the result printed , to use in other function.

Here is the code:

"Keyword idea text '%s' has %d average monthly searches and competition as %d.%s", $result->getText()->getValue(), is_null($result->getKeywordIdeaMetrics()) ? 0 : $result->getKeywordIdeaMetrics()->getAvgMonthlySearches()->getValue(), is_null($result->getKeywordIdeaMetrics()) ? 0 : $result->getKeywordIdeaMetrics()->getCompetition(), PHP_EOL ); return 

The result is like : Keyword idea text 'a' has 1600 average monthly searches and competition as 4. Keyword idea text 'b' has 10 average monthly searches and competition as 2. Keyword idea text 'c' has 10 average monthly searches and competition as 4.

this is how is printed

i want to return like "a,b,c"

How to store this result in one string and to retunr ....so then i can use in other function