fastapi_django_main_live / command /line /get_user_profile.py
kenken999's picture
fa
8f10d41
raw
history blame contribute delete
573 Bytes
import requests
def get_user_profile(user_id, access_token):
url = f'https://api.line.me/v2/bot/profile/{user_id}'
headers = {
'Authorization': f'Bearer {access_token}'
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
profile = response.json()
user_name = profile.get('displayName')
user_thumbnail = profile.get('pictureUrl')
return user_name, user_thumbnail
else:
print(f"Failed to get user profile: {response.status_code}, {response.text}")
return None, None