google / php-photoslibrary Goto Github PK
View Code? Open in Web Editor NEWPHP client library for the Google Photos Library API
Home Page: http://developers.google.com/photos
License: Apache License 2.0
PHP client library for the Google Photos Library API
Home Page: http://developers.google.com/photos
License: Apache License 2.0
Descriptions that contain unicode characters are ignored when calling batchCreateMediaItems(..)
.
We have verified this by using the string КОНТАКТНЫЙ ТЕЛЕФОН
.
This does not appear to be an issue in the API itself, but rather an issue with the encoding of strings when making the request.
thanks for the good examples, I would like to know how to connect to bees without passing from the google windows authorization for example for a server-to-server functionality
Sorry for my poor english.
I downloaded sample from this repo, and change line 36 of albums/index.php
from
$pagedResponse = $photosLibraryClient->listAlbums();
to
$pagedResponse = $photosLibraryClient->listAlbums(['pageSize' => '5']);
but i got all 58 albums back.
i want to manage the recently upload media, could we add a sort method to sort media by upload time
network in china cannot reach google api directly
i will be the only one using it , on the backend server side meaning 1 user only i tried saved token on a file but how do i refresh because it expires after 1 hour
Is it correct use:
php-photoslibrary/src/common/common.php
Line 94 in dde4b9a
I search everywhere and refresh_token is the one that actually are used to refresh access_token. Here are actually access_token used as refresh_token. Or I missed something here?
Hi,
When making a call to searchMediaItems, the response object does not contain the methods of SearchMediaItemsResponse, only PagedListResponse, therefore I am unable to retrieve the next page token.
$photosLibraryClient = new PhotosLibraryClient(['credentials' => $credentials]);
$response = $photosLibraryClient->searchMediaItems(['pageSize' => 50]);
$response->getNextPageToken() is undefined
Trying to run example code from docs but it fails with this error:
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://oauth2.googleapis.com/token` resulted in a `400 Bad Request` response:
{
"error": "unsupported_grant_type",
"error_description": "Invalid grant_type: "
}
in /media/G/BFHome/Projects/Web/GooglePhoto/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /media/G/BFHome/Projects/Web/GooglePhoto/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /media/G/BFHome/Projects/Web/GooglePhoto/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /media/G/BFHome/Projects/Web/GooglePhoto/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /media/G/BFHome/Projects/Web/GooglePhoto/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Pr in /media/G/BFHome/Projects/Web/GooglePhoto/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
Code I've tried to run:
<?php
require('vendor/autoload.php');
use Google\Auth\Credentials\UserRefreshCredentials;
use Google\Photos\Library\V1\PhotosLibraryClient;
use Google\Photos\Library\V1\PhotosLibraryResourceFactory;
$credentials = json_decode(file_get_contents('credentials.json'), true);
$credentials = $credentials['installed'];
$credentials['refresh_token'] = null; // fails with error "Missing required parameter: refresh_token" without setting it
$scopes = array(
'https://www.googleapis.com/auth/photoslibrary.readonly',
//'https://www.googleapis.com/auth/photoslibrary',
'https://www.googleapis.com/auth/photoslibrary.sharing',
'https://www.googleapis.com/auth/photoslibrary.appendonly',
'https://www.googleapis.com/auth/photoslibrary.readonly.appcreateddata'
);
$authCredentials = new UserRefreshCredentials(
/* Add your scope, client secret and refresh token here */
$scopes,
$credentials
);
$photosLibraryClient = new PhotosLibraryClient(['credentials' => $authCredentials]);
$newAlbum = PhotosLibraryResourceFactory::album("Example Album");
$createdAlbum = $photosLibraryClient->createAlbum($newAlbum);
$albumId = $createdAlbum->getId();
The error occurs when calling $photosLibraryClient->createAlbum($newAlbum)
.
When I run composer require google/photos-library
I get this error:
google/photos-library dev-main requires php ^5.5 || ^7.0 -> your php version (8.0.5) does not satisfy that requirement.
Is there anything specific that is incompatible with PHP 8, or should the platform requirements be simply changed to >=5.5
, which doesn't exclude PHP 8?
When $photosLibraryClient->batchCreateMediaItems($newMediaItems, ['albumId' => $albumId]);
Error:
vendor/google/gax/src/ApiCore/Transport/RestTransport.php:153
Error occurred during parsing: String specified for bool or submessage field: creation_time
Error message is clear:
InvalidArgumentException: Passing in the "body" request option as an array to send a POST request has been deprecated. Please use the "form_params" request option to send a application/x-www-form-urlencoded request, or the "multipart" request option to send a multipart/form-data request.
Please update library.
EDIT: ok, it is more google/gax issue than this one, but media uploading is broken currently.
I am using credentials.json file to access clientid, redirecturl, and so on. is it safe to use from json file, because we can access it from direct url
hi
php 7.3 got "PHP Fatal error: Uncaught Error: Class 'Google_Service_PhotosLibrary' not found"
composer.json:
{
"require": {
"google/photos-library": "^1.7",
"google/apiclient": "^2.14"
}
}
please help
thanks
While authenticate i got this error
Fatal error: Uncaught InvalidArgumentException: json key is missing the refresh_token field in C:\xampp\htdocs\gphotos\vendor\google\auth\src\Credentials\UserRefreshCredentials.php:78 Stack trace: #0 C:\xampp\htdocs\gphotos\config.php(49): Google\Auth\Credentials\UserRefreshCredentials->__construct(Array, Array) #1 C:\xampp\htdocs\gphotos\index.php(5): connectWithGooglePhotos() #2 {main} thrown in C:\xampp\htdocs\gphotos\vendor\google\auth\src\Credentials\UserRefreshCredentials.php on line 78
Hi, the library dont support resumable upload?
I am trying to play with this example but am running into the problem that it apparently uses a template from League/Plates/Engine, without 'require'-ing any script. I tried adding
'use League/Plate/Engine'
to common/common.php, hoping that the server that I am working on had the templates installed, but this does not help.
I am a bit new to standalone php development, so far have been working on a Joomla! website, which had a lot of the boiler plate stuff taken care of.
Do you have any suggestion how to get going with the samples without the League templates and/or how to get a minimal version of it downloaded?
Thanks, Marco.
I am getting the error below when calling any method on a PhotosLibraryClient object. I read on stackoverflow that this could be due to a missing bcmath extension but enabling this (via composer) did not help.
Fatal error: Uncaught Error: Call to undefined function Google\Protobuf\Internal\bccomp() in /app/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php:933 Stack trace: #0 /app/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1218): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue('1242', Object(Google\Protobuf\Internal\FieldDescriptor)) #1 /app/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1167): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl(Array) #2 /app/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(815): Google\Protobuf\Internal\Message->mergeFromJsonArray(Array) #3 /app/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1218): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue(Array, Object(Google\Protobuf\Internal\FieldDescriptor)) #4 /app/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1167): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl(Array) #5 /app/vendor/google/protobuf/src/ in /app/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php on line 933
There is a dead link to samples on the README page (under review the samples
), and the sample itself is missing some key components, such as php
syntax in the code blocks, a use
statement for the PhotosLibraryClient
class, and an explanation for $_SESSION['credentials']
.
I would submit a PR but my understanding is all of this is automatically generated. Or are the READMEs maintained separately? If so I can submit some fixes.
One of the test of current main
branch code is failing on PHP version 5.5.
I bet originally the method was setExpectedException
from phpunit
4.8.36
. It is likely somebody refactored it to expectException
since he/she might be working on new PHP version (perhaps 7.0?) which implies newer version of phpunit
which setExpectedException
is definitely deprecated.
Should we stop supporting PHP version 5.5
and support newer PHP version and then replace those deprecated methods?
Although I use the parameter "access_type = offline" the token expires and I can not work offline for more than 1 hour.
The error message is:
{
"error": "invalid_grant",
"error_description": "Token has been expired or revoked."
}
And the code is
$authCredentials = new UserRefreshCredentials( [ 'https://www.googleapis.com/auth/photoslibrary.sharing', 'https://www.googleapis.com/auth/photoslibrary' ], [ 'client_id' => $this->client_id, 'refresh_token' => $this->refreshToken, 'client_secret' => $this->clientSecret, ] );
How can I renew the token without user intervention?
Type: Error
Message: Call to undefined method Google\Photos\Library\V1\NewMediaItem::setFileName()
Filename: ..vendor/google/photos-library/src/Google/Photos/Library/V1/PhotosLibraryResourceFactory.php
Line Number: 100
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.