1. Go to this page and download the library: Download google/photos-library library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
google / photos-library example snippets
// [START sample_usage]
use Google\Auth\Credentials\UserRefreshCredentials;
use Google\Photos\Library\V1\PhotosLibraryClient;
use Google\Photos\Library\V1\PhotosLibraryResourceFactory;
try {
// Use the OAuth flow provided by the Google API Client Auth library
// to authenticate users. See the file /src/common/common.php in the samples for a complete
// authentication example.
$authCredentials = new UserRefreshCredentials( /* Add your scope, client secret and refresh token here */ );
// Set up the Photos Library Client that interacts with the API
$photosLibraryClient = new PhotosLibraryClient(['credentials' => $authCredentials]);
// Create a new Album object with at title
$newAlbum = PhotosLibraryResourceFactory::album("My Album");
// Make the call to the Library API to create the new album
$createdAlbum = $photosLibraryClient->createAlbum($newAlbum);
// The creation call returns the ID of the new album
$albumId = $createdAlbum->getId();
} catch (\Google\ApiCore\ApiException $exception) {
// Error during album creation
} catch (\Google\ApiCore\ValidationException $e) {
// Error during client creation
echo $exception;
}
// [END sample_usage]