친구 목록을 못 받아 오고 있습니다

코드:
import requests,sys
import json

#1.
with open(r"F:\PycharmProjects\카카오톡 메세지\kakao_code.json",“r”) as fp:
tokens = json.load(fp)
#2.

with open(“kakao_code.json”,“r”) as fp:

tokens = json.load(fp)

print(tokens)

print(tokens[“access_token”])

sys.exit()

friend_url = “https://kapi.kakao.com/v1/api/talk/friends

GET /v1/api/talk/friends HTTP/1.1

Host: kapi.kakao.com

Authorization: Bearer {ACCESS_TOKEN}

headers={“Authorization” : "Bearer " + tokens[“access_token”]}

result = json.loads(requests.get(friend_url, headers=headers).text)

print(type(result))
print("=============================================")
print(result)
print("=============================================")
friends_list = result.get(“elements”)
print(friends_list)

print(type(friends_list))

print("=============================================")
print(friends_list[0].get(“uuid”))
friend_id = friends_list[0].get(“uuid”)
print(friend_id)

결과:
<class ‘dict’>

{‘elements’: [], ‘total_count’: 0, ‘after_url’: None, ‘result_id’: ‘zbnYtN-AsoKyhrOEtIa36N3v2Ore67TGo8St3qrPvdi844Xkkv2P5pL3qJnGp8un-JP8o9XmEw’, ‘favorite_count’: 0}

[]

Traceback (most recent call last):
File “4_get_friends_list.py”, line 33, in
print(friends_list[0].get(“uuid”))
IndexError: list index out of range

조언 부탁드리겠습니다.

image

안녕하세요~

아래 FAQ 에서

“1단계. 팀멤버 추가하여 친구목록 조회 테스트 하기 체크 리스트” 확인해보시겠어요?