Fetch details by id

30 views
Skip to first unread message

denma test

unread,
Aug 5, 2020, 4:23:37 AM8/5/20
to AdWords API and Google Ads API Forum
I want to get Campaign, Adgroups and Ads data(like, name, budget, targetings and so on) by using the id from API. Anyone please guide me to get it done.

Google Ads API Forum Advisor Prod

unread,
Aug 5, 2020, 1:52:44 PM8/5/20
to denm...@gmail.com, adwor...@googlegroups.com
Hello,

Thank you for reaching out. Using the respective get() methods within CampaignService, AdGroupService, and AdService will allow you to retrieve data on Campaign, AdGroup and Ad, respectively. You will be able to filter your requests by id by using Google Ads Query Language. For sample code on how this can be accomplished, you can refer to the "Basic Operations" section under code samples on this documentation. 

Let me know if you have additional questions or require clarification. 

Regards,
Danica, Google Ads API Team

ref:_00D1U1174p._5004Q23HjQE:ref

denma test

unread,
Aug 6, 2020, 12:54:00 AM8/6/20
to AdWords API and Google Ads API Forum
So you mean that i need to call respective getter method to fetch details right. However am using Adwords API v201809, please share link respective to this. Thanks.

Google Ads API Forum Advisor Prod

unread,
Aug 6, 2020, 1:13:34 PM8/6/20
to denm...@gmail.com, adwor...@googlegroups.com
Hello,

Yes, you will have to use the get() methods within each service to pull the data you are looking for. Here are the respective links to the services you are looking for in AdWords API: For code samples, you can refer to this documentation. If you have additional questions, please don't hesitate to ask. 

denma test

unread,
Aug 7, 2020, 5:47:57 AM8/7/20
to AdWords API and Google Ads API Forum
Thanks for the quick response, i have done with Campaign and AdGroups data using get method, working on Ads part, if any will ask you. FYI - added part of my code to get campaign details, the same way done for adgroups, please correct me if am in wrong way.

$session = self::setSession();
        $adWordsServices = new AdWordsServices();
        $campaignService = $adWordsServices->get($session, CampaignService::class);
        $campaignId = intval($campaignId);
        // $campData = array();
        $campData = [];

        // Create a campaign with PAUSED status.
        $campaign = new Campaign();
        $campaign->setId($campaignId);

         // Create a campaign operation and add it to the list.
        $operation = new CampaignOperation();
        $operation->setOperand($campaign);
        $operation->setOperator(Operator::SET);
        $operations[] = $operation;

        // Fetch the campaign from the server.
        $result = $campaignService->mutate($operations);

denma test

unread,
Aug 7, 2020, 7:01:02 AM8/7/20
to AdWords API and Google Ads API Forum

I may did mistake, have used SET but it for update operation instead that i may need to use selectors with get method as in below
$selector = new Selector();
        $selector->setFields(['Id']);
        $selector->setPredicates(
            [
                new Predicate('Id', PredicateOperator::IN, [$creativeId])
            ]
        );

        $res = $campaignService->get($selector);
Am i right here

Google Ads API Forum Advisor Prod

unread,
Aug 7, 2020, 3:48:03 PM8/7/20
to denm...@gmail.com, adwor...@googlegroups.com
Hello,

Can you please clarify what you are looking to accomplish with your code snippet? In your first snippet, I can see that you are creating a campaign and then retrieving it. However, it is unclear what you are looking to do in your second snippet. Kindly clarify so that I may guide you in the right direction. Additionally, our team does not provide support in implementing code, but we are able to help resolve any errors or issues you encounter during your implementation.
Reply all
Reply to author
Forward
0 new messages