在过去的两周里,我一直在与谷歌广告公司( Google )争夺MCC Accounts
,但我无法实现我想要的目标。
我把App.Config弄清楚了
<GoogleAdsApi>
<!-- API-specific settings -->
<add key="DeveloperToken" value="XXXXXXX"/>
<!-- OAuth2 settings -->
<add key="AuthorizationMethod" value="OAuth2" />
<add key = "OAuth2ClientId" value = "XXXXXXX.apps.googleusercontent.com" />
<add key = "OAuth2ClientSecret" value = " XXXXXXX " />
<add key = "OAuth2Mode" value="APPLICATION"/>
<add key = "OAuth2RefreshToken" value = "1//0gd2 XXXXXXX " />
</GoogleAdsApi>
这是我目前正在使用的代码。
Public Sub GetMCCAccounts(ByVal client As GoogleAdsClient)
Dim customerService As CustomerServiceClient = client.GetService(Services.V8.CustomerService)
Dim customerResourceNames As String() = customerService.ListAccessibleCustomers()
For Each customerResourceName As String In customerResourceNames
Dim ManagerCustomerId = customerResourceName.Substring(customerResourceName.IndexOf("/") + 1)
TextBox1.AppendText(vbCrLf & ManagerCustomerId)
Next
End Sub
我没有得到正确的结果。我希望的MCC帐户不会出现在输出中。我得到了不同的帐号。我遗漏了什么?
预期MCC帐户
我正在寻找这10个MCC帐户。
子帐户设置概述
输出
我得到了这16个帐号。
64xxxxxxxx
71xxxxxxxx
10xxxxxxxx
88xxxxxxxx
32xxxxxxxx
58xxxxxxxx
31xxxxxxxx
73xxxxxxxx
98xxxxxxxx
22xxxxxxxx
48xxxxxxxx
37xxxxxxxx
98xxxxxxxx
94xxxxxxxx
88xxxxxxxx
43xxxxxxxx
发布于 2021-07-07 06:10:42
在点燃午夜的油门后,我终于成功地破解了它!
这最终给了我我想要的MCC账户。
Imports Google.Ads.GoogleAds.Lib
Imports Google.Ads.GoogleAds.V8.Services
Imports Google.Ads.GoogleAds
Imports Google.Ads.GoogleAds.V8.Resources
Imports Google.Api.Gax
Imports Google.Apis
Public Class GoogleAdsCode
Private Const PAGE_SIZE As Integer = 1000
'~~> Get MCC Accounts
Public Shared Function GetMCCAccounts(MgrId As Long?) As List(Of String)
Dim googleAdsClient As New GoogleAdsClient
Dim googleAdsServiceClient As GoogleAdsServiceClient = googleAdsClient.GetService(Services.V8.GoogleAdsService)
Dim customerServiceClient As CustomerServiceClient = googleAdsClient.GetService(Services.V8.CustomerService)
Dim seedCustomerIds As New List(Of Long)
Dim MgrList As New List(Of String)
seedCustomerIds.Add(MgrId.Value)
Const query As String = "SELECT
customer_client.client_customer,
customer_client.level,
customer_client.manager,
customer_client.descriptive_name,
customer_client.currency_code,
customer_client.time_zone,
customer_client.id
FROM customer_client
WHERE customer_client.level <= 1"
Dim customerIdsToChildAccounts As Dictionary(Of Long, List(Of CustomerClient)) = New Dictionary(Of Long, List(Of CustomerClient))()
For Each seedCustomerId As Long In seedCustomerIds
Dim unprocessedCustomerIds As Queue(Of Long) = New Queue(Of Long)()
unprocessedCustomerIds.Enqueue(seedCustomerId)
Dim rootCustomerClient As CustomerClient = Nothing
While unprocessedCustomerIds.Count > 0
MgrId = unprocessedCustomerIds.Dequeue()
Dim response As PagedEnumerable(Of SearchGoogleAdsResponse, GoogleAdsRow) = googleAdsServiceClient.Search(MgrId.ToString(), query, pageSize:=PAGE_SIZE)
For Each googleAdsRow As GoogleAdsRow In response
Dim customerClient As CustomerClient = googleAdsRow.CustomerClient
If customerClient.ToString.Contains("MCC") Then MgrList.Add(customerClient.Id & " (" & customerClient.DescriptiveName & ")")
Next
End While
Next
Return MgrList
End Function
End Class
https://stackoverflow.com/questions/68265386
复制相似问题