Skip to main content
 首页 » 编程设计

python之如何仅使用客户 ID 链接 Google Adwords API 中的帐户

2025年04月02日14yxwkf

我很难理解 Google 的 API 文档,希望能在这里得到一些帮助。

对我来说,作为一个非常新的开发者,Google API 文档毫无意义。

我正在使用 google adwords Python 库,这段代码可能会有用:https://github.com/googleads/googleads-python-lib/blob/b80b8b3741a55f1d00c5974bc58f92540663c6f6/examples/adwords/v201603/account_management/create_account.py .但是,我需要通过发出邀请并将其标记为待处理来链接一个已经存在的帐户。我不是要创建一个新帐户。

那么我从哪里开始用 Python 编写呢?我不理解文档,只需要根据给定的客户 ID 创建一个帐户。任何提示和技巧都会很棒!

请您参考如下方法:

要将现有帐户链接到您的 MCC 帐户,您还需要使用 ManagedCustomerService,特别是 mutateLink 方法。 在 Python 中,它看起来像这样:

# Create the service object 
managed_customer_service = client.GetService('ManagedCustomerService', version='v201605') 
 
# Construct the operation, operator "ADD" and status "PENDING" results in a new invitation 
operation = { 
    'operator': 'ADD', 
    'operand': { 
        'managerCustomerId': YOUR_MCC_ACCOUNT_ID, 
        'clientCustomerId': ACCOUNT_ID_TO_BE_INVITED, 
        'linkStatus': 'PENDING', 
        'pendingDescriptiveName': 'Some text that helps identifying the invitation', 
        'isHidden': False  # This can be used to hide the account in your MCC to decrease clutter 
    } 
} 
 
# Send the operation 
response = managed_customer_service.mutateLink([operation]) 
 
# Print out the resulting ManagedCustomerLink 
pprint.pprint(response.links[0]) 

请注意,我没有测试这段代码,但它应该能让您大致了解它的工作原理。查看reference guide了解更多详细信息以及客户帐户接受邀请后如何继续。