How to retrieve Google+ oAuth2 profile thumbnail picture - php

After a long learning curve, I managed to successfully get the user's profile information using the Google API client libraries.
Along with a name and email address, when the user logs in to my web app, I can get their profile picture.
Trouble is, the picture is pretty big, in dimension and bytes. The url for such a picture looks something like this:
https://lh4.googleusercontent.com/-rdhxDPbmVhg/AAAAAAAAAAI/AAAAAAAAAJQ/6Dsr5psyQPs/photo.jpg
(Yes, that is me at Coral Castle).
Is there a way to get a thumbnail or icon-sized profile pic, like the kind I see next to the author in the results of a Google search? I notice these aren't a URL, but a data object, so I will probably have to do something in php to render it as an image?
An example of the image info on an author, in the results list of a Google search, looks something like this:
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4QBgRXhpZgAASUkqAAgAAAACADEBAgAHAAAAJgAAAGmHBAABAAAALgAAAAAAAABQaWNhc2EAAAMAAJAHAAQAAAAwMjIwAqAEAAEAAAAsAAAAA6AEAAEAAAAsAAAAAAAAAP/bAIQAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsVFhAUExQVFRcMDxcUFhQTFxQVEAEDBAQGBQYJBgYKEg0LDhIVEBAQFBEQEw8UDhUQFRAQDxAQDxEQFA8NEA8QDQ0QDw0ODBAQEAwMDBAPDw8MDA8P/8AAEQgALAAsAwERAAIRAQMRAf/EABkAAAMBAQEAAAAAAAAAAAAAAAYHCAkFAf/EADIQAAEDAwIEBAQFBQAAAAAAAAECAwQFBhEAIQcSMUETIlGBCCNxkRQyYZLBFTNSocL/xAAaAQACAwEBAAAAAAAAAAAAAAAEBQIDBgcB/8QALxEAAQMDAQQJBAMAAAAAAAAAAQACAwQRITEFEkFREyJhcYGRobHBFCPR8EJi4f/aAAwDAQACEQMRAD8AzPjsKlQ6iAQCGEn7vtJ/61DSytOiZPDHgA5xImRk0tmS/F5EeNIkHw0BePOBjGwPfOdKKiv6G4da/Ls4J3Q7MdUAG2Oaf1b+A56ZbzjdM/prM5KeZB5FkqI7Feds/Q6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fXYHOq4WDfF9PhC1MpDHEageqkHjtw5pF30mFUKk6+mWuap1ciK2hLrylIVzKcUUkqz5M9D5RvnpoKd5jkeOAGnZjRY+Zom3OBcde08SuFaPw8WbIowVJo635AedQtanXVZKVkdlbYAG2iTVdJ1o7gcsXHevZaD6d5iebkcQDY4vi6T9lXbSLMqjsipBS47sZxrwhjzqJGM5I21HonSRSMGrhZDTlolheP4u3jz0Ix25RVwxvo0mh1BFNTLqEJh1YlPK5PD5MoUhQwonPXm9OZPXzECu2dI4Em2OX++KdDa0W8N0HPO3Pv1tYKruFXFK34sSP4clyRKcSUiKwlSnE+g5cbe+NK/p36OTZ1ZHa7U97Itx7iO3VEz21Q4LzS2VNEBXgNrSUkq7FZBOB/GmFLROneAzQan4HaktXXiBhc/U6D5Uo8ebiiUC559pNxXJEmLVH0pbV2ZQvyEHPXBT+7Vs8JZJIB3fvglVLXQEMdKSLEE4S0l1enNTJJRUqpHccdWtxqI4EISoqONt9+Xl++NRgiYGDfAv4/Bzy8AmNbtkSzF0Uh3MW6o0t/YX1ufFJywYcSoypQnxGZ7CUgmPIBKF9Tg4IPUDvphNgsAxql8ZvFKT2e6aPCWDBlcK1uNwI0QTXJ7jjbCMJHIlsAAEnY4Gc56DGNH5ZTyPBz+lLo7PmjYRgo94I1F2Bbi6k0EfjGo5KHFJzg6QTCxstNHkAquaNKVZFfuybTAA5CoUqQEOkqS8tnkU2XBkc2+T7n110EsbBT7rBhuQubzPdLIXuOTqoNZqcq4K1Xq9UX1zKq86ouSHdypR86j9SpRz7emsHK4m1+OSiHYACXNQqDzUlRSrdz5iie6judXNaCEaBhf/9k=
I welcome help in getting me to clarify the question, if needed.

You can adjust the size of the image by appending a ?sz=(size in pixels) parameter to the URL you got.
Example
https://lh4.googleusercontent.com/-rdhxDPbmVhg/
AAAAAAAAAAI/AAAAAAAAAJQ/6Dsr5psyQPs/photo.jpg?sz=50
Will display as
What method are you using to retrieve the user information?
The people.get method of the Google+ API called with userId=me for the authenticated User will already return a URL with a ?sz=50 parameter added in the image.url field of the response.

Just pass a parameter for size to the URL ?sz=200
It will become something like https://lh3.googleusercontent.com/--sahsjak8sjdbs5kNk/AAAAdshjgdshdgAAI/AAAAsdhsHY/knQ6LGqP1Yk/photo.jpg?sz=200
And you are good to go!

Related

Android app how to get photos of a specific user

I'm creating a social app similar to instagram on Android studio.
Users will be able to upload and view photos in this app.
The photos are saved on a Cloud in a folder called "ProfileImage" and the URL of the photos is saved on the MySql database, along with the ID of the photo and the user's ID.
To get the photos I would like to use Picasso.
If for example the user A wants to look at his photos, the app will have to show him only his photos, that is I will have to get the URLs of the photos that have the id of the user A.
Picasso to get the photos use the following code Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView);
But the problem is that I don't know the specific URL of the photos.
One solution I thought of is to get the URLs of the photos via PHP and pass them into an android variable that I will use as a URL variable for Picasso.
But this solution seems slow to me, in the sense that the photo will not be displayed immediately, but seconds will have to pass.
Can anyone recommend a faster and perhaps better solution than mine?
First of all, Upload your image to server and save image url inside mysql database not image itself. Create one api that returns user info including image url.

Fetch user Data using user image?

There is Any way or Method to find user information by using user image.
Suppose that: i have one person image by using this image, can we get user information from google+, facebook, and other social sites.
If you could use Google Image search by example programatically, you might be able to do it.
In practice, the user image on other pages might look the same but they will be compressed with different algorithms, so you can't compare them byte-wise.
All in all, it is much easier to ask the user to add the info.
You could try submitting the image to TinEye here and that does a reverse search, so it will show you all other places where that photo appears on the web.

Get Facebook images based upon a description

I need to create a program which allows to store photos of which people has uploaded in Facebook based on the photo description. For example, I upload/post on Facebook a picture with the description "#awesomeevent" the program should be able to store this particular image into the database. Twitter has hashtags but Facebook do not any where which i can work around this ?
I was thinking of using a FQL query but unsure how to do it.
The best (and only?) way to do this imho is to include the hashtag in the message of the photos and read it from there. I would not use FQL for that, because there is no need to use it. The Graph API offers enough possibilities/connections to read photos:
https://developers.facebook.com/docs/reference/api/user/
(/me/photos, /me/photos/uploaded, /me/albums, ...)

How can i get the profile picture of a user who have registered my website via the facebook social plugin

I have a registration plugin embeded via an iframe on my website, The registration plugin works fine , I am also able to get the unique user_id of each user by using the following line of code in the signed_request file which can be located here
The line of code i use to get the user_id is: $response["user_id"];
Now that i have a unique id of each user, i want a way by which i can get the link to the profile image of that user, i know i can get the thumbnail of the profile picutre
using open graph,
But i am looking for a way by which i can get the link to the complete or the original profile picture, not the thumbnail.
Is there a way this can be done? Using open graph or something like that?
You need user_photos permissions first. Then something like this should do it:
SELECT cover_object_id FROM album WHERE owner=me() and type='profile'
Substitute me() with the user you are querying for.
It returns the photo object that you can then use to pull the full version from.
Make an API call to /user_id/?fields=picture using the access_token in the same signed_request

Facebook: How to add a Tag to a Fan page in the Caption of the Photo uploaded to users profile

I have seen a Fan page wall being tagged in a photos caption.
http://www.facebook.com/photo.php?fbid=165019486869988
Notice its in the Caption itself, and its a Fan page that was tagged, not a person.
How was this done? I actually cant even see how to do it manually on Facebook.
Can it be done in a Facebook PHP App? If so how?
So when my application posts to the users "Application Photo Album" the caption would have a link back to my apps fan page or app page.
This would all involve databases, and I have done something like this before. It is pretty involved the way facebook does it because they also link back to the tagged users page.
You would have to have a unique user ID for each user and a unique photo ID for each photo.
When a person pulls up the image the web site would query the MySQL Database and look for the record that matches the Photo ID, then it would look for the tagged User ID's that are attached to that Photo ID, which would be stored under that database record when the user was tagged.
The web site would then echo out the results of the database query to retrieve all of the tagged User ID's and you would have to then make the User ID's appear as the users name, which would require a function to take that User ID and query another database that will retrieve the users actual name and return it to the script.
The question you asked is very general and I can go on all day about the technicalities behind it, but I hope this gave you a general idea of how it can be done with PHP/MySQL.
Please let me know if you have any questions!!
I figured out that you can tag a fan page if you actually upload the image via your wall "Post Picture" then in the status message as your posting it you can tag the fan page #FanPage just like when you tag a friend in your status message.
Still not able to do this via programming.
Well i found a simpler solution to the same that uses the graph api
http://developers.facebook.com/docs/reference/api/photo/
You can specify which user to tag using two methods: in the URL path as PHOTO_ID/tags/USER_ID, or in a URL parameter as PHOTO_ID/tags?to=USER_ID. To add several tags at once, you can specify a tags property which contains an array of tags like so PHOTO_ID/tags?tags=[{"id":"1234"}, {"id":"12345"}]. Currently, you cannot tag a Page in a photo using this API.
Tagging a photo requires the user_photos and publish_stream permissions, publish_stream is optional - if not present, the tag will go through Tag Review of the tagged person if s/he has this privacy setting enabled. Tagging a photo supports the following parameters.
Hope this resolves the issue

Categories