【问题标题】:Google adwords customers API is not returning customers list?Google adwords 客户 API 没有回头客列表?
【发布时间】:2021-04-12 03:18:30
【问题描述】:

我有以下代码来获取广告经理帐户下的所有广告客户列表,我正在使用经理凭据来获取客户列表。

public Customer[] GetAllManagerClientsList(string currentUserEmail, string authorizationCode)
    {
        string baseURL = _configuration.GetValue<string>("URL:SiteURL");
        var currentUser = _userRepository.GetIntegratedAppsDetailByEmail(currentUserEmail);
        AdsOAuthProviderForApplications oAuth2Provider = (user.OAuthProvider as AdsOAuthProviderForApplications);
        oAuth2Provider.Config.OAuth2RedirectUri = baseURL + "/google-auth-callback";

        oAuth2Provider.FetchAccessAndRefreshTokens(authorizationCode);

        //Get customerID
        user.Config.OAuth2AccessToken = oAuth2Provider.Config.OAuth2AccessToken;
        user.Config.OAuth2RefreshToken = oAuth2Provider.Config.OAuth2RefreshToken;
        CustomerService customerService = (CustomerService)user.GetService(AdWordsService.v201809.CustomerService);
        var customersList = customerService.getCustomers();

        var ClientCustomers = customersList != null && customersList.Length > 0 ? customersList.Where(c => c.canManageClients == false).ToList() : null;
        if (ClientCustomers.Count() > 0)
        {
            return ClientCustomers.ToArray();
        }
        else
        {
            return null;
        }
    }

【问题讨论】:

    标签: ads google-ads-api


    【解决方案1】:

    法鲁克 你的问题是什么?你在看什么?目前还不清楚问题是什么。

    编辑: 你用 Google-Ads-API 标记了这个,这是旧的 API。下面的代码适用于新的 Google Ads API,但如果您需要使用旧的 API,可能会为您指明正确的方向。

    您使用的是正确的服务,只是方法不正确。您需要使用 list_accessible_customers() 方法:

    def get_mccs_and_direct_admin_only_accounts(client):
    customer_service = client.get_service('CustomerService', version='v6')
    
    try:
        accessible_customers = customer_service.list_accessible_customers()
    
        resource_names = accessible_customers.resource_names
        for resource_name in resource_names:
            print('Customer resource name: "%s"' % resource_name)
    

    【讨论】:

    • 有一个广告经理帐户作为广告经理,并且该经理有持有谷歌广告广告账户的客户,我正在将谷歌广告 API 集成到我的项目中,所以我正在点击谷歌 API 来获取我下面的所有客户/客户列表,但 Api 没有返回我的客户。这是谷歌自己提供的谷歌服务。 CustomerService customerService =(CustomerService)user.GetService(AdWordsService.v201809.CustomerService); var customersList = customerService.getCustomers();
    • 鉴于您提供了问题/说明,我已经更新了我的答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多