Adwords Api 如何在广告级别暂停广告

Posted

技术标签:

【中文标题】Adwords Api 如何在广告级别暂停广告【英文标题】:Adwords Api How to Pause Ads on Ad level 【发布时间】:2020-06-23 18:35:01 【问题描述】:

我正在尝试使用 AdId 和 AdGroupID 暂停广告。我已成功暂停了一个 AdGroup,但我想单独暂停广告。这在 Adwords API 上是否可行。我尝试了下面的代码,但它似乎只适用于 AdGroup 级别。还检查了 AdService,但似乎没有编辑状态的选项。 我正在使用 Ads.AdWords.v201809 提前致谢

    public void googleEnableDisableAds(AdWordsUser user, long adGroupId, long AdID, AdGroupAdStatus AdStatus)
    
        using (AdGroupAdService adGroupAdService =
             (AdGroupAdService)user.GetService(AdWordsService.v201809.AdGroupAdService))
        
            List<AdGroupAdOperation> operations = new List<AdGroupAdOperation>();


            // Create the expanded text ad.
            ExpandedTextAd expandedTextAd = new ExpandedTextAd
            
                //CR[i].                              
                id = AdID
            ;

            AdGroupAd expandedTextAdGroupAd = new AdGroupAd
            
                adGroupId = adGroupId,
                ad = expandedTextAd,

                // Optional: Set the status.
                status = AdStatus
            ;

            // Create the operation.
            AdGroupAdOperation operation = new AdGroupAdOperation
            
                @operator = Operator.SET,
                operand = expandedTextAdGroupAd
            ;

            operations.Add(operation);

            AdGroupAdReturnValue retVal = null;

            try
            
                if (operations.Count > 0)
                
                    // Create the ads.
                    retVal = adGroupAdService.mutate(operations.ToArray());

                    // Display the results.
                    if (retVal != null && retVal.value != null)
                    
                        foreach (AdGroupAd adGroupAd in retVal.value)
                        
                            ExpandedTextAd newAd = adGroupAd.ad as ExpandedTextAd;
                            Console.WriteLine(
                                "Expanded text ad with ID '0' and headline '1 - 2' " +
                                "was added.", newAd.id, newAd.headlinePart1, newAd.headlinePart2);
                            //adGroupId                      
                        
                    
                    else
                    
                        Console.WriteLine("No expanded text ads were created.");
                    
                

                adGroupAdService.Close();
            
            catch (Exception e)
            
                throw new System.ApplicationException("Failed to create expanded text ad.", e);
            
        
    

【问题讨论】:

【参考方案1】:

这是来自 API 文档 https://developers.google.com/adwords/api/docs/samples/csharp/basic-operations#pause-an-ad 的示例

关键思想是将status属性设置为PAUSED

AdGroupAdStatus status = AdGroupAdStatus.PAUSED

【讨论】:

以上是关于Adwords Api 如何在广告级别暂停广告的主要内容,如果未能解决你的问题,请参考以下文章

使用 adwords api 管理广告的成本

如何使用 google adwords api 获取所有广告系列详细信息?

如何使用 Google Adwords API 从广告系列中获取否定关键字列表

使用 Adwords API 将自定义受众添加到广告组

如何使用 google click id (GCLID) 提取 AdWords 广告系列、广告组、关键字、广告等

google adwords api + 获取所有关键字