简体   繁体   English

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

[英]How to access google photos using api in php?

I want to fetch all the photos on Google photos on my web site using php.我想使用 php 获取我网站上 Google 照片上的所有照片。 Is it possible?.有可能吗? I know Picasa Web Albums Data API deprecated.我知道 Picasa 网络相册数据 API 已弃用。 I have got try it from Picasa.我已经从 Picasa 尝试过了。 but i am not able to download library from https://developers.google.com/gdata/articles/php_client_lib .但我无法从https://developers.google.com/gdata/articles/php_client_lib下载库。

There is currently no Google Photos API.目前没有 Google 相册 API。 The only thing available is Picasa.唯一可用的是 Picasa。 You may be able to upload the pictures to your google drive account and display them on your website that way.您可以将图片上传到您的 Google Drive 帐户并以这种方式显示在您的网站上。 However your probably going to have to set the pictures to public.但是,您可能必须将图片设置为公开。

There is an API now for Google photo's.现在有一个用于 Google 照片的 API。 But I've not been successfull in making it work myself但我没有成功地让它自己工作

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

I am trying to do the same thing, so far, I setup the api:我正在尝试做同样的事情,到目前为止,我设置了 api:

  1. From Google Console API --> enabled the photos library api.从 Google Console API --> 启用照片库 API。
  2. Following this example : https://github.com/google/google-api-php-client/blob/master/examples/simple-query.php I managed to setup the api with the following code :按照这个例子: 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';
    # create client
    $client = new Google_Client();
    $client -> setApplicationName("Client_Library_examples");

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

    $client -> setDeveloperKey($apiKey);

The autoload and base.php files were copied from the mentioned link. autoloadbase.php文件是从提到的链接复制的。 I copied my api to a file .apiKey .我将我的 api 复制到一个文件.apiKey Up to this point, the code works fine, the example in the previous link explains how to create a new google service for e-books.到目前为止,代码运行良好,上一个链接中的示例解释了如何为电子书创建新的谷歌服务。 There must be a similar thing for google photos but couldn't find any yet.谷歌照片一定有类似的东西,但还没有找到。

I found the following but I am not getting anything with the echo :我发现了以下内容,但我没有得到任何与 echo 相关的信息:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 (PHP)使用oauth和服务帐户访问私人Google Photos(Picasa Web)API信息 - (PHP) Using oauth and service accounts to access private Google Photos (Picasa Web) API info 如何使用FB API从PHP专辑中获取照片 - How to get photos from facebook album with PHP using FB API Google Ads API - 如何使用 PHP 获取访问和引用令牌 - Google Ads API - How to get the access and referesh token using PHP 如何使用 php 获取带有谷歌 api 授权码的访问令牌? - How fetch access token with auth code for google api using php? 使用API​​从Google +中的帖子访问照片? - Accessing Photos from Posts in Google + using API? 如何在Google相册API中使用可选参数? - How to use optional parameters in Google Photos API? 如何通过API获取PHP照片? - How to get instagram photos with PHP by API? 我如何使用FB API for php获取所有照片 - how can i fetch all my photos using FB API for php 如何使用PHP上传照片/文件到服务器 - How to upload photos/file to server using PHP 如何使用 PHP Api 访问 Google Cloud Storage Buckets 及其对象 - How to access Google Cloud Storage Buckets and its objects using a PHP Api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM