Up until now, we used the Google Plus API to get a user's public photo. All we needed was the user id to get the photo (as described here).
Now that this and the Picasa APIs are being deprecated, the only alternative I found is using the Users.photos API (as described here).
As you can see in the description, this API requires authorization, although the deprecated APIs did not, and the photo I wish to get is public. Not all of our users login with Google, but I want to be able to show everyone the public photos of the users which did login with Google. Is there any way to do this now?
You can use the people.get
method of the Google People API to get the information you need with just the user ID. While you can get public information without the user's token, you will need an API key. You also won't be able to get the information if it isn't public.
You need to request exactly which fields you want. The "names" and "photos" fields will probably be the ones most important to you, but there are others available. You'll get an array of possible values, each indicating their source. You will probably want the source type of "PROFILE", but you can certainly evaluate others.
So if you issued a request with
GET https://people.googleapis.com/v1/people/101852559274654726533?personFields=names%2Cphotos&key={YOUR_API_KEY}
You'll be asking for my public profile. You'll get back a response something like
{
"resourceName": "people/101852559274654726533",
"etag": "%EgYBAj0DNy4aDAECAwQFBgcICQoLDA==",
"names": [
{
"metadata": {
"primary": true,
"verified": true,
"source": {
"type": "PROFILE",
"id": "101852559274654726533"
}
},
"displayName": "Allen “Prisoner” Firstenberg",
"familyName": "Firstenberg",
"givenName": "Allen",
"displayNameLastFirst": "Firstenberg, Allen"
}
],
"photos": [
{
"metadata": {
"primary": true,
"source": {
"type": "PROFILE",
"id": "101852559274654726533"
}
},
"url": "https://lh5.googleusercontent.com/-RDndFau_En4/AAAAAAAAAAI/AAAAAAAB8CY/sTL9kJMmIgk/s100/photo.jpg"
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With