如何在PHP中使用api访问谷歌照片?

时间:2018-04-09 06:10:49

标签: php google-api google-api-php-client google-api-client

我想使用php在我的网站上获取Google照片上的所有照片。 可能吗?。我知道Picasa网络相册数据API已被弃用。我从Picasa试了一下。但我无法从https://developers.google.com/gdata/articles/php_client_lib下载库。

3 个答案:

答案 0 :(得分:0)

目前没有Google相册API。唯一可用的是Picasa。您可以将图片上传到Google云端硬盘帐户并以这种方式显示在您的网站上。但是,您可能需要将图片设置为公开。

答案 1 :(得分:0)

Google照片现在有一个API。 但是,我自己并没有成功地使它成功

https://developers.google.com/photos/

答案 2 :(得分:0)

我正在尝试做同样的事情,到目前为止,我已经设置了api:

  1. 从Google Console API->启用了照片库api。
  2. 按照以下示例:https://github.com/google/google-api-php-client/blob/master/examples/simple-query.php 我设法使用以下代码设置了api:

    include_once DIR 。 '/vendor/autoload.php'; include_once'base.php';

    创建客户端

    $ client = new Google_Client(); $ client-> setApplicationName(“ Client_Library_examples”);

    if(!$ apiKey = getApiKey()){     回声missingApiKeyWarning(); }

    $ client-> setDeveloperKey($ apiKey);

autoloadbase.php文件是从上述链接中复制的。我将api复制到文件.apiKey。 到目前为止,代码工作正常,上一个链接中的示例说明了如何为电子书创建新的Google服务。谷歌照片肯定有类似的东西,但找不到。

我发现了以下内容,但回声什么也没有得到:

$response = file_get_contents('https://photoslibrary.googleapis.com/v1/albums');
$response = json_decode($response);
echo $response
相关问题