0
votes

I know how to retrieve google+ profile pic from url but recently google+ started to use vanity urls for verified users.

WORKS https://plus.google.com/s2/photos/profile/110031535020051778989?sz=100

DOES NOT WORK https://plus.google.com/s2/photos/profile/+BarackObama?sz=100

Is there a work around to get a profile pic for the vanity url users?

Note: I know you can get the same info through Google+ API but that dose not allow me to change image size so I would like to use above way.

1

1 Answers

4
votes

You can change the size for images returned by the Google+ API.

The request

https://www.googleapis.com/plus/v1/people/%2BBarackObama?key={YOUR_API_KEY}

will return a response with the following image.url

https://lh6.googleusercontent.com/-2lJYGtfXKwQ/AAAAAAAAAAI/
AAAAAAAA_1g/zw7Opav6CIk/photo.jpg?sz=50

You can just change the ?sz=50 parameter to whatever size you want the image to be, similar to how you do for the URLs you mentioned.

If you really want to use URLs of the kind you mentioned you can use the same request and then take the id from the response which will be the numeric ID you can use.

But I'm not aware that the URLs you mentioned are officially documented somewhere (correct me if I'm wrong) so they might change/stop working without prior notice. Going through the Google+ API is probably the safer way.