I have used google app engine with django application. I have been using the user api from google to login in my website and also getting the current user email address from that, but i have to get profile picture which is uploded on the google plus account.
I am getting their profile picture using,
<img src="https://plus.google.com/s2/photos/profile/<user_id>?sz=100" width="100" height="100">
in google api.
User class also provides user_id but I cannot get their profile picture using that user_id.
<user_id> and user_id of user class of Google API is different.
How to get the profile picture in my application?
The way to do it is to use the google+ api here: https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get?userId=me&_h=2&
This is the request to pull the image for the currently authenticated user.
GET https://www.googleapis.com/plus/v1/people/me?key={YOUR_API_KEY}
You'll get a json response like this and it's really easy to parse that and pull out the image->url value to display.
{
"kind": "plus#person",
"etag": "\"XxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXx\"",
"gender": "male",
"emails": [
{
"value": "jbrahy#XxXxXxXx.com",
"type": "account"
}
],
"objectType": "person",
"id": "XxXxXxXxXxXxXxXxXxXxXxXx",
"displayName": "John Brahy",
"name": {
"familyName": "Brahy",
"givenName": "John"
},
"url": "https://plus.google.com/XxXxXxXxXxXxXxXxXxXxXxXx",
"image": {
"url": "https://lh3.googleusercontent.com/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/photo.jpg?sz=50"
},
"isPlusUser": true,
"language": "en",
"circledByCount": 2,
"verified": false,
"cover": {
"layout": "banner",
"coverPhoto": {
"url": "https://lh5.googleusercontent.com/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/XxXxXxXx/Green%2BGrass.jpg",
"height": 240,
"width": 420
},
"coverInfo": {
"topImageOffset": 0,
"leftImageOffset": 0
}
},
"domain": "XxXxXxXx-x.com"
}
If you are asking the about the ids...
My GoogleID according to user_id() is xxx8005350796570706xx and my Google Plus profile ID is 102445631084043565507 which are totally different
You need to ask the user for his G+ profile or authenticate him via oAth2.0 to get permissions to read his profile.
Also if you have his email address you could use GAvatar.
Related
How can we get the phone number with Google OAuth API login.
I am using scopes as
'scope' : 'https://mail.google.com https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.login '
and the request is as
var request = gapi.client.plus.people.get({'userId': 'me'});
Is there any scope we can use to get it.
I am getting response as with no sight of phone number :
{
"kind": "plus#person",
"etag": "\"vPymIyv1bT9LfmoUujkgN2yLMK0\"",
"gender": "male",
"emails": [
{
"value": "XXX#gmail.com",
"type": "account"
}
],
"urls": [
{
"value": "http://picasaweb.google.com/XXX",
"type": "otherProfile",
"label": "Picasa Web Albums"
}
],
"objectType": "person",
"id": "4354354334435465",
"displayName": "XXXXX YYYY",
"name": {
"familyName": "XXX",
"givenName": "YYYYY"
},
"url": "https://plus.google.com/1100335464643327",
"image": {
"url": "https://lh3.googleusercontent.com/-fgsdgfgU9-jU/AAAAAAAAAAI/AAAAAAAADkM/fgffdgdkM/photo.jpg?sz=50",
"isDefault": false
},
"isPlusUser": true,
"language": "en",
"ageRange": {
"min": 21
},
"circledByCount": 59,
"verified": false
}
if you want to get user phone numbers you have to have authorization from the user: see the following info page : https://developers.google.com/admin-sdk/directory/v1/guides/authorizing
ask the user for this scope of authorization :
https://www.googleapis.com/auth/admin.directory.user.readonly
after you have authorization from user run the folowing request :
GET https://www.googleapis.com/admin/directory/v1/users/userKey
the response will be a JSON response formatted as followed:
https://developers.google.com/admin-sdk/directory/v1/reference/users#resource
one of the attributes is phone list.
hope it helps.
You can use google's people API to get the user's phone numbers.
To explore more you can try yourself.
Steps to explore:
Visit this link.
Select https://www.googleapis.com/auth/user.phonenumbers.read permission in People API v1 section
Click on Authorize API
Choose the account to log in
Grant permission
Click Exchange authorization code for tokens
Enter https://people.googleapis.com/v1/people/138262720636785143353?personFields=phoneNumbers,emailAddresses link, make sure you replace the UID
Click on send request to see the response
When integrating a Facebook App with oauth.io, the latest API version we can choose is v2.3.
The login process works though, but, when trying to retrieve the user data (/me), only the elements name and id are being delivered in the raw data from the oauth.io response:
curl "https://oauth.io/auth/facebook/me"
-H “oauthio:k=<myOauthKey>&access_token=<fbAccessToken>"
we get following response:
{
"status": "success",
"data":
{
"id": "fbId",
"avatar": "https://graph.facebook.com/v2.3/fbId/picture",
"name": "User Name",
"gender": 1,
"url": "https://www.facebook.com/fbId",
"raw":
{
"name": "User Name",
"id": "fbId"
}
}
}
If we make the call directly using Facebook, I can get extra fields if I specify them in the URL:
curl "https://graph.facebook.com/v2.5/me?access_token=<fbAccessToken>
&fields=name,email,gender,birthday,first_name,last_name,picture"
we get the data we are looking for:
{
"name": "User Name",
"email": "email\u0040email.com",
"gender": "female",
"birthday": "03/02/1994",
"first_name": "User",
"last_name": "Name",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/hprofile-xlt1/v/t1.0-1/p50x50/whatever"
}
},
"id": "fbId"
}
The reason is clear: since v2.4 Facebook requires the fields parameter to retrieve the extra data. See Fewer default fields for faster performance under https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
Do you know if there is any way to tell oauth.io to fill the fields parameter when calling the facebook /me call?
Btw, using:
https://oauth.io/auth/facebook/me?fields=name,email,gender,birthday
does not work.
Oauth.io has fixed the issue and is available from 1.0.0-beta.18
https://github.com/oauth-io/oauthd/commit/7beec64ab39955c3afd2eb28ecf7288c74ccdc96
I'm working on an Android application and I'm trying to obtain contact pictures from friends. I'm still testing the graph request on the Facebook Graph API Explorer linkhere I'm going to use afterwards in the code, and I've hit a snag...
After generating an Access Token, and validating it allows me access to the correct fields I'm interested, I'm trying to filter the information I'm obtaining from Facebook.
Using the Facebook Graph API Explorer I'm performing the following request:
< USER_ID>?fields=id,first_name,last_name,location,picture,birthday,photos.limit(3).fields(id,picture,source,from)
I obtain, as expected:
{
"id": "<USER_ID>",
"first_name": "<FIRST>",
"last_name": "<LAST>",
"photos": {
"data": [
{
"id": "<PICTURE1>",
"source": "<PIC1.jpg>",
"from": {
"name": "<OTHER_USER1>",
"id": "<OTHER_USER1_ID>"
},
"created_time": "2013-08-17T11:39:19+0000"
},
{
"id": "<PICTURE2>",
"source": "<PIC2.jpg>",
"from": {
"name": "<OTHER_USER2>",
"id": "<OTHER_USER2_ID>"
},
"created_time": "2013-08-04T14:27:07+0000"
},
{
**"id": "<PICTURE3>"**,
"source": "<PIC3.jpg>",
"from": {
"name": "<USER>",
**"id": "<USER_ID>"**
},
"created_time": "2013-08-03T17:35:20+0000"
}
],
"paging": {
"previous": "<LINK1>",
"next": "<LINK2>"
}
},
"picture": {
"data": {
"url": "<PIC>",
"is_silhouette": false
}
}
}
What I would like is to only obtain the pictures from ... like the third picture or others, is this possible using the graph api?
Thanks for the help.
Marc
PS:
I've tried adding in the end something like &photos.data.from.id=< USER_ID>
but I till get the same data set in response.
I would like to avoid requesting more pictures and filter it programmatically, because You never know how many pictures are associated with a user that where not submitted by that user.
Not possible with the Graph API, but you can use FQL, to query for the photos of the user (not those in which he's tagged in) -
SELECT pid,src FROM photo WHERE owner = me()
Check FQL - Photo to include the required fields in the result.
I am using facebook android sdk for accessing facebook albums. I've got the json that contains all the albums object. Want to get the cover photo of each album.
This is the object:
"id": "3486732467234",
"from": {
"name": "Persons Name",
"id": "Persons ID"
},
"name": "Vacation",
"location": "City",
"link": "https://www.facebook.com/album.php?fbid=434235&id=324343&aid=2430",
"cover_photo": "3489234432",
"privacy": "everyone",
"count": 60,
"type": "normal",
"created_time": "2007-06-03T23:01:16+0000",
"updated_time": "2011-03-18T19:46:43+0000",
"can_upload": true
}
How can i get the cover_photo image with this value "cover_photo": "3489234432" ??
I am able to get this value in a string..
Thanks
just request photo info by photoID, use this API:
https://graph.facebook.com/photoID
Don't forget the access_token
I'm reading my user's friend's wall posts with the Graph API "/637674567/posts". One of the data items is that he likes a photo. Is there a way to get a URL for the photo? When I get the information about the item, I get the following (below). I've verified that Darryl allows apps to see his photos and status updates. I've tried getting every permission available for my app. I can't figure it out. Any help? Thanks!
{
"id": "637674567_10151119619094448",
"from": {
"name": "Darryl Green",
"id": "637674567"
},
"story": "Darryl Green likes a photo.",
"story_tags": {
"0": [
{
"id": 637674567,
"name": "Darryl Green",
"offset": 0,
"length": 19,
"type": "user"
}
]
},
"type": "status",
"application": {
"name": "Likes",
"id": "2409997254"
},
"created_time": "2012-08-29T03:29:03+0000",
"updated_time": "2012-08-29T03:29:03+0000",
"comments": {
"count": 0
}
}
Your friend might have enabled apps to access his photos. But there is another level of privacy setting, that is what kind of data can the apps his friend (you) use, be able to access from his feed ?
Chances are, if those settings don't allow for access to his photos when you are trying to access them via your app, you won't be able to do so.
For a more detailed explanation, please check this reply - http://facebook.stackoverflow.com/a/12151338/1628782.