BASE_URL = ‘https://apis.moment.kakao.com’
ACCESS_TOKEN = ‘’
AD_ACCOUNT_ID = ‘’
광고계정 실시간 잔액 정보 가져오기
def get_balance():
print(BASE_URL)
print(ACCESS_TOKEN)
print(AD_ACCOUNT_ID)
uri = '/openapi/v4/adAccounts/balance'
headers = {
'Authorization': f'Bearer {ACCESS_TOKEN}',
'adAccountId': str(AD_ACCOUNT_ID)
}
print(headers)
r = requests.get(BASE_URL + uri, headers=headers)
print(r)
if r.status_code == 200:
data = r.json()
balance = data['cash'] + data['freeCash']
return balance
else:
print(f"API 요청 실패: {r.status_code}")
return None
토큰이랑 account id 잘 넣어도 401오류가 뜨는데 왜 그러는 걸까요??