Get information about friends of friends using the graph API - facebook-graph-api

I need to get some information about friends of friends of my user.
Specifically, I would like to get their name, age, picture, friends list, groups, interests, likes etc.
I'm fairly new to the whole FB API, and I'd be very thankful for any help.
Thanks. :)

Check out the Graph API Explorer.
It is basically a sandbox for building up api calls to get information about your users.
Here is an example of the request you can send off to Facebook and the response you can get back:
https://graph.facebook.com/<FBID>?fields=id,name,friends.fields(last_name)&method=GET&format=json&access_token=<ACCESS_TOKEN>
And the response:
{
"id": "<MY FBID>",
"name": "<MY NAME>",
"friends": {
"data": [
{
"last_name": "<FRIEND LAST NAME>",
"id": "<FRIEND FBID>"
},
{
"last_name": "<FRIEND LAST NAME>",
"id": "<FRIEND FBID>"
},
etc...

Related

GSuite - Last email activity

I am trying to create a GSuite integration using GSuite Admin SDK that will fetch a list of users and the datetime of their last activity. I am able to fetch last login time, but I can't find a way to find the last email activity for a user that uses POP or IMAP email clients.
The data that I am trying to fetch is available in the admin console:
But is there a way to fetch it using Gsuite Admin SDK?
I found a solution to get the email activities for users, but the examples in the API reference were not so straight-forward, and they were spread out on several pages. I ended up using User Usage Report from the GSuite Reports API (as suggested in a comment on the original question): https://developers.google.com/admin-sdk/reports/v1/guides/manage-usage-users
Sample call:
GET https://www.googleapis.com/admin/reports/v1/usage/users/all/dates/2018-05-21?parameters=classroom:last_interaction_time,accounts:last_login_time,accounts:last_sso_time,gmail:last_access_time,gmail:last_imap_time,gmail:last_interaction_time,gmail:last_pop_time,gmail:last_webmail_time
This way I was able to get not only email activities, but also Classroom last interaction time and GSuite last login time and Last SSO time.
Sample user response:
"entity": {
"type": "USER",
"customerId": "customerId",
"userEmail": "sample#email.com",
"profileId": "profileId"
},
"parameters": [
{
"name": "classroom:last_interaction_time",
"datetimeValue": "1970-01-01T00:00:00.000Z"
},
{
"name": "accounts:last_login_time",
"datetimeValue": "2018-05-18T14:46:11.000Z"
},
{
"name": "accounts:last_sso_time",
"datetimeValue": "1970-01-01T00:00:00.000Z"
},
{
"name": "gmail:last_access_time",
"datetimeValue": "2018-05-18T08:43:15.000Z"
},
{
"name": "gmail:last_imap_time",
"datetimeValue": "1970-01-01T00:00:00.000Z"
},
{
"name": "gmail:last_interaction_time",
"datetimeValue": "2018-04-23T07:08:40.000Z"
},
{
"name": "gmail:last_pop_time",
"datetimeValue": "1970-01-01T00:00:00.000Z"
},
{
"name": "gmail:last_webmail_time",
"datetimeValue": "2018-04-23T07:08:44.000Z"
}
]

How do I find which facebook messenger apps are linked with a facebook page through the facebook graph api?

I have been trying this out in the graph api explorer. Here are the steps I have been following:
Get a user access token with the permissions publish_actions, ads_management, manage_pages, publish_pages, pages_messaging, pages_messaging_phone_number, pages_messaging_subscriptions, pages_show_list, and user_events.
I GET the me/accounts endpoint and get this object:
{
"data": [
{
"access_token": "thisIsWhereTheAccessTokenGoes",
"category": "Shopping & Retail",
"category_list": [
{
"id": "200600219953504",
"name": "Shopping & Retail"
}
],
"name": "Some Page",
"id": "123456789",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
}
],
"paging": {
"cursors": {
"before": "MTk1NDA4MDM2NDYyMDY5MAZDZD",
"after": "MTk1NDA4MDM2NDYyMDY5MAZDZD"
}
}
}
I copy the access token and page id from the above page object and paste it into the graph api explorer in the appropriate places.
I GET the endpoint {page-id}/subscribed_apps
I get this empty array:
{
"data": [
]
}
However if I go to my facebook app dashboard and go to the messenger settings and generate a page access token for the same page that I was getting in the graph api explorer, and then I paste that token into the explorer and get the {page-id}/subscribed_apps endpoint I actually get the app info that I was looking for. Something like this:
{
"data": [
{
"link": "https://www.facebook.com/games/?app_id=555555555555",
"name": "Test Messenger Bot",
"id": "555555555555"
}
]
}
I thought this could be because my app was in testing mode, but I tried to create a bot on chatfuel and linked it to the same facebook page and could not see that app listed under subscribed_apps either. I am thinking there is maybe some kind of permissions issue? I appreciate any help on this.

Oauth.io only gets "name" and "id" in the raw data from Facebook v2.4 and v2.5

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

Facebook graph API obtain a specific users's pictures from that same user

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.

Why is there information available while browsing that is not available using the graph api?

There is profile information, like interests, education and work history, that is available to me when I am browsing profiles of users who are not my friends (while logged in and while logged out).
However this information is not available using the graph api, using an access token given by my user with the maximum permissions possible.
Why is that? Am I doing something wrong or is that the policy of Facebook to expose more information while browsing the site than while using the graph api?
I guess this is how things works when using the API, you could confirm this easily by hitting the Graph of any user (without even connecting to Facebook):
https://graph.facebook.com/zuck
Result:
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Now with a user access_token I got a couple more fields:
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "https://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US",
"updated_time": "2011-10-02T21:26:46+0000",
"type": "user"
}
So back to your question:
Does Facebook expose more information about public profiles while browsing the site than
while using the graph api?
YES