1

我被困在这个 API 上。我想打印传入的 json 文件(具体的通道点),但它只是以 html 格式打印整个页面。这是我的代码:

import requests
import json

client_id = secret
oauth_token = secret

my_uri = 'https://localhost'

header = {"Authorization": f"Bearer {oauth_token}"}

url = f'https://id.twitch.tv/oauth2/authorize?client_id={client_id}&redirect_uri={my_uri}&response_type=id_token&scope=channel:read:redemptions+openid&state=c3ab8aa609ea11e793ae92361f002671&claims={"id_token":{"email_verified":null}}'

response = requests.get(url, headers=header)

print(response.text)

url我的假设是header问题所在。twitch API 最初是为 c# 或 js 制作的,但我不知道如何将这些信息转换为 python。

我也想知道如何做 Twitch 在 API 中写的“PING”和“PONG”的事情

4

2 回答 2

0

response.text显示html文本

response.json显示 json

告诉我它现在是否有效

于 2020-12-21T22:23:20.890 回答
0

response.json() will return you the data in JSON format

于 2020-12-24T07:57:35.897 回答