Fetch Google Plus Profile Picture using PHP
Profile URL schema
Before launching the Google plus, Google's user profiles URL schema was something like thishttp://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 schema
Ok lets talk about profile image, You can get a profile image by ID (or mail ID too) here is the urlhttps://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 URL
Its 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 = "something@gmail.com";
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
Labels: google+, hacks, php, Tip, Tutorials
By : Motyar+ @motyar6 comments
SenthilKumar says…
andy says…
Prabhu says…
praveena says…
https://profiles.google.com/s2/photos/profile/116599978027440206136?sz=48
pH4Lk0n says…
Armin says…
Thanks


Post a Comment