Entries in me/feed from current user to group - facebook-graph-api

Recently me/feed started to include entries sent by current user to groups.
The id field is invalid for those entries and simply returns "false".
Changing the first part of the id to the one mentioned in "to" gives a valid entry.
It could be a good workaround except there is no way to immediately know which posts are normal and which posts are to Groups.
I did notice that on posts to groups there is an extra field 'version' that is not documented. Anyone knows what this field means?
Example entry:
...
"id": "1188060277_343671429042688",
"from": {
"name": "My Name",
"id": "1188060277"
},
"to": {
"data": [
{
"version": 1,
"name": "Group Name",
"id": "194744830602016"
}
]
},
...

Hope this helps :)
groups
The Groups that the user belongs to.
user_groups or friends_groups.
An array of objects containing the version(old-0 or new Group-1), name, id, administrator (if user is the administrator of the Group) and bookmark_order(at what place in the list of group bookmarks on the homepage, the group shows up for the user).
http://developers.facebook.com/docs/reference/api/user/

Related

Get list of users with name, phone number and group memberships from G Suite

I have looked into the G Suite admin APIs and found this function:
GET https://www.googleapis.com/admin/directory/v1/users
I get a list of all users, but no users in the list have a phone number. How can I include the user's phone number in the list?
I would also like to know how to get a list of every user's group memberships if this is possible.
The phone number property is under user Resource which you might have missed since it's also located in the Users.list under Response.
{
"kind": "admin#directory#users",
"etag": etag,
"users": [
users Resource
],
"nextPageToken": string
}
which when you click leads to the full User Resources which then contains the phones property including others.
"phones": [
{
"value": string,
"primary": boolean,
"type": string,
"customType": string
}
],
"phones": string

Query Group Feed Posts by `created_time`

For a small Facebook Sales Group Monitor I need to query the group's new posts. I've intended to do this via the Graph API, requesting only posts which have been either
created since the last query (created_time) or
updated since the last query (updated_time).
This, however, seems not to be possible.
Omitting all non-date fields, a GET /v2.7/<group-id>/feed request returns the following data:
"data": [
{
"updated_time": "2016-01-12T20:11:02+0000",
"created_time": "2014-09-16T09:55:39+0000",
"id": "552364968142715_789142084465001"
},
{
"updated_time": "1970-01-01T00:16:40+0000",
"created_time": "2016-08-28T19:15:53+0000",
"id": "552364968142715_1183108935068312"
},
{
"updated_time": "1970-01-01T00:16:39+0000",
"created_time": "2016-08-29T14:13:22+0000",
"id": "552364968142715_1183722648340274"
},
{
"updated_time": "1970-01-01T00:16:38+0000",
"created_time": "2016-08-28T09:15:05+0000",
"id": "552364968142715_1182673285111877"
},
...
]
The first entry is from the pinned group-rules post, created in 2014, updated 2016.
The second and fourth entries are both from yesterday, the third post is from today.
All but the first post have updated_time-timestamps close to the UNIX epoch's beginning. With a few exceptions, the value seems to be decreasing by 1 second for every post in the list, even when requesting 100+ posts.
The API Reference for Group feeds states, that the since=<timestamp> query parameter only applies on the updated_time field, which does not help in this case.
Is there any way to filter for or at least sort by the created_time value?
I am running into same problem. It seems currently created_time only apply for Page feed, not Group feed at the moment :(

What is a correct way to handle writable M2M relationship in djangorestframework?

I have a many to many relationship between a Contact and a ContactGroup. One contact can belong to many groups, one group can contain multiple contacts.
I want to be able to display data like this, so I don't need to do multiple queries when showing names of groups where an user belongs.
GET
{
"id": 1,
"name": "Gandalf",
"groups": [
{
"id": 3,
"name": "Lord of the rings"
}
]
}
But if I update, I want to be able to update using ids or urls e.g.
POST
{
"id": 1,
"name": "Gandalf",
"groups": [
[2]
]
}
That would remove it from group 3 and put it to group 2 instead. I know I should write a Writable nested serializer, but I have two questions:
1) I want to do this properly, what is supposed to be a good practice when I want to do this. Shall I send ids or the whole objects like
POST
{
"id": 1,
"name": "Gandalf",
"groups": [
{
"id": 2,
"name": "Wizards"
}
]
}
This one seems a bit weird to me as I need to send information that is not needed (name in this case).
2) If I can go with id/url principle, how shall I do this? In a custom create/update method, I can't have id validated, because a serializer points to a GroupSerializer and doesn't accept int type, it expects GroupSerializer, so accessing validated_data.get('groups') wouldn't get me ids, it would tell me [{"non_field_errors":["Invalid data. Expected a dictionary, but got int."]}]}
I can write 2 serializers - one for create/update and one from displaying data. Do you think it's a correct way of doing this? Am I doing a right think in a first place? What do you think of this approach?
For #1, you can leave the name as read only field in which case you'll have it for read and it'll be discarded for write operations.
For #2 as you want to remain consistent, your best take it to send:
POST
{
"id": 1,
"name": "Gandalf",
"groups": [
{"id": 2}
]
}
You really don't want to have a different style for read and write operations, really.

facebook group members Bio information

I am interested in retrieving a Facebook group members' Bio information.
I have created an app where I have requested permission of about user_about_me and the app is under review for submission.
I have coded for the app in JSP but it can only select name, gender, last_name, first_name only. It is not selecting the Bio information.
I face the same problem even in the graph API explorer, when I use
{group_ID}/members
I can retrieve list of all group members. But I can not see more details than the following:
"data": [
{
"name": "name",
"administrator": false,
"id": "USER ID"
},
..
When I click on the ID (or enter the ID in the explorer), I can only get the following:
{
"id": "member_ID",
"first_name": "firstname",
"last_name": "lastname",
"link": "https://www.facebook.com/app_scoped_user_id/...",
"name": "name ",
"updated_time": "2015-02-07T10:02:58+0000"
}
This is not showing the Bio information.
when I enter the following:
{member_ID}?fields=bio
I just get
{
"id": "10153223503039309"
}
I will appreciate if someone please identify me the problem. I believe this problem will also solve my code problem, where at the moment I am unable to retrieve the group member's Bio information too.
Is it possible that the problem will be resolved after the app's acceptance, which is under review?
Thanks you very much.
Syed
You canĀ“t just grab more information from the user just because he is a member of some group. You would have to let him authorize your App with the correct permissions in order to get more data.

Why does FQL return different user IDs to Graph API

I want to see which users can see a particular album. I use the following query to get my albums and their privacy settings:
SELECT id,allow,deny,description,friends,value FROM privacy WHERE id IN
(SELECT object_id FROM album WHERE owner=me())
and it returns something like this for each album:
{
"id": 212102865605678,
"allow": "211824028961234,212367312342178",
"deny": null,
"description": "John Doe, Work People",
"friends": "SOME_FRIENDS",
"value": "CUSTOM"
}
The second ID in the allow column is right. That's the ID for the 'Work People' friendlist.
But the other ID isn't really the ID of 'John Doe'.
If I use the FB.api from javascript using 'me/friends' I get this:
{
"name": "John Doe",
"id": "100005318169867"
}
Same name, but different ID. I'm quite certain that they're the same user (I don't have many friends). Is this the difference between some internal database ID and external ID?
Any help would be greatly appreciated!