YouTube分析APIを使用してデータを取得しようとしています。access_token を取得したら、それを使用してリクエストを作成し、ユーザーの情報を取得できます。Python リクエストは次のとおりです。
newurl='https://gdata.youtube.com/feeds/api/users/default?'
token={'v':'2.1', 'access_token':access_token}
urll = newurl + urllib.urlencode(token)
result = urllib.urlopen(newurl + urllib.urlencode(token)).read()
次に、同じ access_token を使用して、次のような 2 番目の要求を作成しようとしました。
newurl2='https://www.googleapis.com/youtube/analytics/v1/reports'
newtoken={'v':'2.1',
'start-date':'2010-10-10',
'end-date': ###current time###,
'metrics':'views,comments,likes,dislikes,shares',
'ids':'channel==' ###user_id###,
'access_token':access_token}
result = urllib.urlopen(newurl2 + urllib.urlencode(newtoken)).read()
しかし、ここでエラーが発生しました:
"code": 401,
"message": "Invalid Credentials"
PHP を使用しているときに 2 番目の要求を正常に作成できますが、Python を使用してエラーが発生した理由がわかりません。誰か助けてもらえますか?? ありがとう!!