Sep 29, 2011
Fetch Google Plus Profile Picture using PHPGoogle plus APIs are out now, you can fetch profile images or avatar using that too. But I am here to show you how you can fetch google plus profile image without using their API. Simple and short, and no call limit.
Profile URL schemaBefore launching the Google plus, Google's user profiles URL schema was something like this
http://profile.google.com/GoogleIdHere, For example my Google profile link was https://profile.google.com/dharmmotyar or https://profile.google.com/116599978027440206136
On Google Plus its https://plus.google.com/116599978027440206136
Profile Image URL schemaOk lets talk about profile image, You can get a profile image by ID (or mail ID too) here is the url
https://profiles.google.com/s2/photos/profile/GoogleIdHere, mine is https://profiles.google.com/s2/photos/profile/116599978027440206136
Note: This is not the permalink to profile picture, this will redirect you.
Using PHP to get Picture URLIts simple with PHP, we are just fetching where its redirecting us, we are going to use a old trick, here is the code:
$headers = get_headers("https://profiles.google.com/s2/photos/profile/".$id, 1); $PicUrl = $headers['Location'];
You can use it for mail id like this
$email = "firstname.lastname@example.org"; list($id, $domain) = split("@",$email); $headers = get_headers("https://profiles.google.com/s2/photos/profile/".$id, 1); $PicUrl = $headers['Location'];
You can Discussion and Commets on Google plus
By : Motyar+ @motyar