forbidden (403) forbidden Access forbidden. The request may not be properly authorized.
答:您所做的請求沒有被批准。更新:更改鍵=到ACCESS_TOKEN =
可能的原因:
https://www.youtube.com/annotations_invideo?key=
您正在嘗試運行的請求annotations_invideo
(我不能真正找到任何人的文檔中),你所申請一個API密鑰。 API密鑰只適用於公共數據。 annotations_invideo
不是對API的有效請求,也不是您需要驗證的內容。如果您需要進行身份驗證,那麼您需要一個訪問令牌,然後應用access_token=
而不是key=
您究竟在哪裏找到annotations_invideo?
更新:
幸運的是我,因爲你發佈你的問題,我能夠採取
https://www.youtube.com/annotations_invideo?access_token=AIzaSyBSvIOM0EGX1tcrf5IAlYJuH_ttqVgTO4Q&video_id=BPNYv0vd78A
並在它返回的數據網絡瀏覽器轉儲它一直在一個小時內。
<document>
<annotations>
<annotation author="" id="annotation_1585555999" log_data="ei=B2k9WIOCB8X0dNKokKAG&a-id=annotation_1585555999&xble=1&a-type=4&a-v=BPNYv0vd78A" style="title" type="text">
<TEXT>Hello, world!</TEXT>
<segment>
<movingRegion type="rect">
<rectRegion d="0" h="25.2779998779" t="0:00.000" w="75.0" x="13.1540002823" y="67.3239974976"/>
<rectRegion d="0" h="25.2779998779" t="0:02.089" w="75.0" x="13.1540002823" y="67.3239974976"/>
</movingRegion>
</segment>
<appearance bgAlpha="0.25" bgColor="0" borderAlpha="0.10000000149" effects="" fgColor="16777215" fontWeight="bold" highlightFontColor="16777215" textSize="21.6642"/>
</annotation>
<annotation id="channel:563d3ce4-0000-20cc-8fd5-001a11463304" style="playlist" type="promotion" log_data="ei=B2k9WIOCB8X0dNKokKAG&a-type=12&a-ch=UCwCnUcLcb9-eSrHa_RQGkQQ&xble=1&a-id=563d3ce4-0000-20cc-8fd5-001a11463304&l-class=2&link-id=PLuW4g7xujBWfU26JUTW1DGs3hk4LD5KaL&a-v=BPNYv0vd78A">
<data>
{"playlist_length":"200","session_data":{"itct":"CAIQwTcY____________ASITCMOh497wzdACFUU6HQodUhQEZCj4HTICaXZIwN_33vSX1vkE","annotation_id":"563d3ce4-0000-20cc-8fd5-001a11463304","feature":"iv","ei":"B2k9WIOCB8X0dNKokKAG","src_vid":"BPNYv0vd78A"},"is_mobile":false,"text_line_2":"Adorable Kids","text_line_1":"Check this playlist","image_url":"https:\/\/i.ytimg.com\/vi\/yDrLVqRHAsw\/mqdefault.jpg","start_ms":1000,"collapse_delay_ms":86400000,"end_ms":3000}
</data>
<segment/>
<action trigger="click" type="openUrl">
<url type="hyperlink" target="new" value="https://www.youtube.com/watch?v=yDrLVqRHAsw&list=PLuW4g7xujBWfU26JUTW1DGs3hk4LD5KaL"/>
</action>
</annotation>
</annotations>
</document>
注意:我想知道爲什麼這是返回XML而不是Json,我認爲這是一個較老的api。發現它你正在使用YouTube API v2 deprecated它應該已經關閉。
https://youtube-eng.googleblog.com/2014/09/have-you-migrated-to-data-api-v3-yet.html
你應該放棄這一點,並移動到YouTube API v3
curl命令是在一個點的建議中的錯誤消息。根據教程(https://www.sitepoint.com/youtube-api-version-3-rails/),該專業版專爲處理YouTube API V3而創建。感謝您的幫助。我會盡力與這個寶石的作者取得聯繫。 – NeimadTL
我使用YT API V3的捲曲結果更新了我的帖子。 – NeimadTL