我执行了 oauth 流程,然后运行以下代码,但我没有得到任何数据;我已经确认
manager_customer_id
确实存在。有什么建议吗?谢谢!
scopes = ["https://www.googleapis.com/auth/adwords"]
# Create an instance of InstalledAppFlow
flow = InstalledAppFlow.from_client_config(
{
"web": {
"client_id": client_id,
"client_secret": client_secret,
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
},
scopes=scopes
)
# Choose a consistent port number for the OAuth callback
# Make sure this port is the same as the one set in your Google Cloud Console redirect URI
#credentials = flow.run_local_server(port=0)
print(f"Running local server for authentication on port {consistent_port}...")
# Run the flow to get the credentials
credentials = flow.run_local_server(port=consistent_port)
print("Authentication successful. Obtained credentials.")
# Use credentials to create a session
session = requests.Session()
session.headers.update({'Authorization': f'Bearer {credentials.token}'})
print("Session created. Preparing API request...")
# Your API request code goes here
url = "https://localservices.googleapis.com/v1/accountReports:search"
params = {
"query": "manager_customer_id:xxxxx",
# "startDate.month": "12",
# "startDate.day": "1",
# "startDate.year": "2023",
# "endDate.month": "12",
# "endDate.day": "31",
# "endDate.year": "2023",
# "pageSize": "500",
}
# Send the GET request using the OAuth session
response = session.get(url, params=params)
# Check if the request was successful
if response.status_code == 200:
print("Successfully received API response.")
data = response.json()
print("Data:", data)
else:
print("Failed to retrieve data. Status code:", response.status_code)
print("Response:", response.text)
我也有同样的问题。 如果我使用此端点请求帐户报告
我得到下面的结果,其中显示一根带电的引线。该潜在客户应显示在潜在客户报告中。
账户报告结果:
{
"accountReports": [
{
"currentPeriodChargedLeads": "0",
"averageFiveStarRating": 4.9,
"phoneLeadResponsiveness": 0.59,
"averageWeeklyBudget": 249.97,
"currencyCode": "EUR",
"impressionsLastTwoDays": "0",
"totalReview": 40,
"currentPeriodConnectedPhoneCalls": "0",
"previousPeriodConnectedPhoneCalls": "1",
"previousPeriodPhoneCalls": "1",
"previousPeriodChargedLeads": "1",
"currentPeriodPhoneCalls": "0",
"businessName": "Fix-xxxxxxxxx",
"previousPeriodTotalCost": 5.12,
"currentPeriodTotalCost": 0,
"accountId": "xxxxxxxx"
}
]
}
尽管如此,对潜在客户报告的请求仅返回一个空的 JSON {}。如果我在更长的时间段内使用 startDate 和 endDate 参数,情况也是如此。
端点领先报告结果:
{}