【问题标题】:Google Photos REST API “BASE_URL=dv” return "302 Moved" errorGoogle 相册 REST API “BASE_URL=dv”返回“302 Moved”错误
【发布时间】:2020-12-27 15:59:46
【问题描述】:

我使用 Google Photos REST API 来下载我的视频。根据文档,我使用下面的 curl 命令和 BASE_URL=dv 参数来获取视频文件并得到 302 Moved 错误,但视频处于 READY 状态。粘贴下面的输出。 请帮助解决错误。

API:

curl --compressed --output - --request GET   --header 'Authorization: Bearer ACCESS_TOKEN'   --header 'Accept: application/json' 'BASE_URL=dv'

输出:

<HTML>
<HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="VIDEO_URL">here</A>.
</BODY></HTML>

【问题讨论】:

    标签: base-url google-photos google-photos-api


    【解决方案1】:

    我相信你的目标如下。

    • 您想使用 curl 命令将视频下载为文件。

    在这种情况下,请使用以下 curl 命令。

    修改 curl 命令:

    curl -L "base-url=dv" -o sampleFilename
    
    • 在这种情况下,似乎不需要使用访问令牌。

    • 请使用-L--location 进行重定向。

    • base-urlhttps://lh3.googleusercontent.com/lr/###时,请使用https://lh3.googleusercontent.com/lr/###=dv作为网址,如下所示。

        curl -L "https://lh3.googleusercontent.com/lr/###=dv" -o sampleFilename
      

    参考资料:

    【讨论】:

    • 您好田池,非常感谢您。它解决了这个问题。另外,我发现curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L) 用于libcurl 的使用。
    猜你喜欢
    • 1970-01-01
    • 2011-09-25
    • 2017-09-13
    • 1970-01-01
    • 2017-09-12
    • 2020-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多