ChatGPT に、LINE APIのコードを聞いてみた。
AIがブーム(?)になっている。ChatGPT に、LINE API でユーザ情報を取得するコードを聞いてみた。便利だね!!URLは書けないので削除していますimport requests
import json
def get_user_profile(user_id, access_token):
headers = {
'Authorization': 'Bearer ' + access_token
}
response = requests.get('URL' + user_id, headers=headers)
if response.status_code == 200:
user_profile = json.loads(response.text)
return user_profile
else:
return None
# Replace 'USER_ID' with the actual user ID
user_id = 'USER_ID'
# Replace 'ACCESS_TOKEN' with your LINE Messaging API access token
access_token = 'ACCESS_TOKEN'
user_profile = get_user_profile(user_id, access_token)
if user_profile:
# Extract user information from th
0