Cant find the Languages set to a Campaign

14 views
Skip to first unread message

Binu Mathew

unread,
Nov 12, 2021, 11:58:00 AM11/12/21
to AdWords API and Google Ads API Forum
Hi All

Here is the code i use get languages set to an individual campaign 

$language_query='SELECT language_constant.id FROM campaign_criterion';
         if ($id !== null) {
            $language_query .= " WHERE campaign.id= $id ";
        }
        $response =$googleAdsServiceClient->searchStream('<account_id> ',$language_query);
      
        foreach ($response->iterateAllElements() as $googleAdsRow) {
            $campaignCriterion = $googleAdsRow->getCampaignCriterion();
            $newCompete = new \StdClass();          
            $newCompete->langauge_code = $campaignCriterion->getLanguage()->getCode();
             array_push($googleAdsRow, $newCompete);
            
        }

This code return following error any idea why ? 

message: "Call to a member function getCode() on null"

Binu Mathew

unread,
Nov 13, 2021, 2:58:33 AM11/13/21
to AdWords API and Google Ads API Forum
Any Information Available ??

Google Ads API Forum Advisor

unread,
Nov 15, 2021, 12:43:13 AM11/15/21
to binumat...@gmail.com, adwor...@googlegroups.com
Hi Binu,

Thank you for posting your concern.

It appears that the code could not properly get the methods under the CampaignCriterionService and this is the possible reason why the error occurred. With this, I would suggest reaching out to the author of the client library via this link to get assistance to this concern and to address the issue. The author of the client library is more equipped to provide support to code related issues / concerns.

Regards,
​​​​​​
Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2R8aA2:ref
Reply all
Reply to author
Forward
0 new messages