【问题标题】:I'm trying to build an app using Google photos API, in which given a person's image, I can get all the images of him/her from Google photos我正在尝试使用谷歌照片 API 构建一个应用程序,其中给定一个人的图像,我可以从谷歌照片中获取他/她的所有图像
【发布时间】:2018-06-14 07:03:39
【问题描述】:

我是新手,这是我关于这个主题的第一个项目。谷歌照片根据面孔对图像进行分组。我想获取与给定人相关的所有照片集或该人所在的照片集。是否有可能做到这一点?如何执行此操作,如果可以,请指定一个好的来源,我可以从中更好地理解 API。 提前致谢!

【问题讨论】:

    标签: google-photos google-photos-api


    【解决方案1】:

    试试这个代码

    点击按钮调用 onAuthPhotoApiLoad 函数

    **还包括google的js **

    var scopeApi = ['https://www.googleapis.com/auth/photoslibrary', 'https://www.googleapis.com/auth/photoslibrary.readonly', 'https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata'];
    
    function onAuthPhotoApiLoad() {
        window.gapi.auth.authorize(
            {
                'client_id': "Put Client ID Here",
                'scope': scopeApi,
                'immediate': false
            },
            handlePhotoApiAuthResult);
    }
    
    
    function handlePhotoApiAuthResult(authResult) {
        if (authResult && !authResult.error) {
            oauthToken = authResult.access_token;
    
                   GetAllPhotoGoogleApi();
        }
    }
    
    
    function GetAllPhotoGoogleApi() {
           gapi.client.request({
            'path': 'https://photoslibrary.googleapis.com/v1/mediaItems:search',
            'method': 'POST',
            'body': {
                "filters": {
                    "mediaTypeFilter": {
                        "mediaTypes": ["PHOTO"]
                    }
                }
            }
        }).then(function (response) {
            console.log(response);     
    
        }, function (reason) {
            console.log(reason);
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 2021-01-13
      • 1970-01-01
      相关资源
      最近更新 更多