Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Google photos API获取所有用户照片?_Api_Gdata_Google Data Api_Google Photos - Fatal编程技术网

如何使用Google photos API获取所有用户照片?

如何使用Google photos API获取所有用户照片?,api,gdata,google-data-api,google-photos,Api,Gdata,Google Data Api,Google Photos,我正在使用访问我的谷歌照片帐户。我的目标是下载给定开始时间和结束时间之间的所有照片(旧假期照片)。这个API不支持服务器端时间过滤,所以我尝试访问最近4000个图像的元数据,并在客户端按时间过滤它们。我有一个工作的概念证明,但我只能让服务器返回约900个图像引用(我的谷歌照片帐户很容易就有40k个图像)。我是否缺少一些API方法,可以让我为我的用户下载整个“提要”,这样我就可以访问我所有照片上的元数据?这是我试过的 # Tried this first, got ~900 results pic

我正在使用访问我的谷歌照片帐户。我的目标是下载给定开始时间和结束时间之间的所有照片(旧假期照片)。这个API不支持服务器端时间过滤,所以我尝试访问最近4000个图像的元数据,并在客户端按时间过滤它们。我有一个工作的概念证明,但我只能让服务器返回约900个图像引用(我的谷歌照片帐户很容易就有40k个图像)。我是否缺少一些API方法,可以让我为我的用户下载整个“提要”,这样我就可以访问我所有照片上的元数据?这是我试过的

# Tried this first, got ~900 results
pics = gd_client.GetUserFeed(kind='photo', limit=4000).entry
# Tried using the paging parameter start-index, but even if I 
# page through until it errors out, there are only ~900 results
pics = gd_client.GetFeed('/data/feed/api/user/default?kind=photo&max-results=100&start-index=500').entry
相册的API可以正确地列出所有图像,“自动备份”相册(在Android手机上接收来自谷歌照片的图像)有30k个图像,我可以查询所有图像的元数据


不幸的是,我不能把这些图片放在一个相册中,并以这种方式下载它们——用户创建的相册仅限于2000张图片。(我知道这次旅行总共有大约3000张图片,因为我可以在web界面中“选择”它们并查看总数,但你不能一次下载那么多,也不能在一张相册中添加超过2k的图片。)

从未让API按照我的期望工作,但我能够“解决”这是通过多次尝试后使用

下载目标日期实现的,我想我已经实现了完美的工作

我所做的是同时使用
开始索引
最大结果

您需要按如下方式执行(考虑到在每个请求中保持
max results
值相同):

  • 开始索引
    =1&
    最大结果
    =您想要的任何值ex:50
  • Url请求如下所示:

    /data/feed/api/user/default?kind=photo&max-results=50&start-index=1
    
    /data/feed/api/user/default?kind=photo&max-results=50&start-index=51
    
    /data/feed/api/user/default?kind=photo&max-results=50&start-index=101
    
  • 开始索引
    =1+先前的
    最大结果
    =51&
    最大结果
    =50
  • Url请求如下所示:

    /data/feed/api/user/default?kind=photo&max-results=50&start-index=1
    
    /data/feed/api/user/default?kind=photo&max-results=50&start-index=51
    
    /data/feed/api/user/default?kind=photo&max-results=50&start-index=101
    
  • 开始索引
    =51+先前的
    最大结果
    =101&
    最大结果
    =50
  • Url请求如下所示:

    /data/feed/api/user/default?kind=photo&max-results=50&start-index=1
    
    /data/feed/api/user/default?kind=photo&max-results=50&start-index=51
    
    /data/feed/api/user/default?kind=photo&max-results=50&start-index=101
    

    以此类推,每次您将
    start index
    增加其原始值,再加上
    max results
    1,再加上每个url请求维护50个条目,它将完美地工作。

    问题。我应该为谁使用Picasa照片分页?我搜索并使用了
    start\u索引
    ,但每次它都没有给我新照片,而是随机获取数据,甚至重复。知道如何正确使用分页吗?不知道。据我所知,他们并不真正关心支持这个API。如果你找到答案,请发帖!我找到了答案并发布了它,以使任何想要解决方案的人受益。