简体   繁体   中英

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. Is it possible?. I know Picasa Web Albums Data API deprecated. I have got try it from Picasa. but i am not able to download library from https://developers.google.com/gdata/articles/php_client_lib .

There is currently no Google Photos API. The only thing available is Picasa. You may be able to upload the pictures to your google drive account and display them on your website that way. However your probably going to have to set the pictures to public.

There is an API now for Google photo's. But I've not been successfull in making it work myself

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

I am trying to do the same thing, so far, I setup the api:

  1. From Google Console API --> enabled the photos library 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 :
    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. I copied my api to a file .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 :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM