Create Multiple Campaign From MYSQL Query

21 views
Skip to first unread message

T.H

unread,
May 11, 2019, 7:15:17 PM5/11/19
to AdWords API and Google Ads API Forum
I have a MYSQL database and I would like to add new campaign for each row I have in the MYSQL table.
The code below creates only one campaign, but I want to create multiple campaigns e.g. each row in the table should be used to create new campaign, please advise.

    // Create connection
    $conn
= mysqli_connect($servername, $username, $password, $dbname);
   
// Check connection

    $sql
= "SELECT * FROM table";
        $result
= $conn->query($sql);
       
       
   
while($row = $result->fetch_assoc()) {
             
       
// Create a campaign with required and optional settings.
        $campaign
= new Campaign();
        $campaign
->setName($row["name"]. uniqid());
        $campaign
->setAdvertisingChannelType(AdvertisingChannelType::SEARCH);

       
       
       
}


googleadsapi...@google.com

unread,
May 13, 2019, 1:11:48 PM5/13/19
to AdWords API and Google Ads API Forum
Hello, 

You will be able to create campaigns using the CampaignService.mutate() operation. You will need to implement a logic on your end to have the created campaign inserted as a new row in the MYSQL table. You may find the AddCampaigns code sample in different languages here

Thanks,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Reply all
Reply to author
Forward
0 new messages