I am trying to read all the posts from my app using the graph path:
/me/home/filter=app_MY_APP_ID.
Among the data returned, some of my actions are grouped together such as:
actions = (
{
link = "https://www.facebook.com/735475141/posts/10153036942300142";
name = Comment;
}
);
application = {
//deleted for app privacy
};
"created_time" = "2013-07-30T14:41:24+0000";
from = {
id = 735475141;
name = "Can Poyrazo\U011flu";
};
id = "735475141_10153036942300142";
privacy = {
value = "";
};
type = link;
"updated_time" = "2013-07-30T14:41:24+0000";
}
When I go to my action (https://www.facebook.com/735475141/posts/10153036942300142) I see 4 photos grouped, with the story title 'X took 4 photos with MY_APP' which is great. But when I try to access that post object from Graph API, I'm getting only one post:
{
"id": "10153036942300142",
"from": {
"name": "Can Poyrazoğlu",
"id": "735475141"
},
"start_time": "2013-07-29T17:46:22+0000",
"end_time": "2013-07-29T17:46:22+0000",
"publish_time": "2013-07-29T17:46:22+0000",
"application": {
//removed for privacy
},
"data": {
"photo": {
"id": "557831850941984",
"url": "https://www.facebook.com/photo.php?fbid=10153036942105142",
"type": //removed for privacy
"title": ""
}
},
//...
}
The 'grouped items' post that I see on the website appears to have reference to only one of the objects in that post at Graph API. How can I access all the actions, if possible, without grouping?
You need to use a different endpoint: /me/<app_namespace>:<action_name>
This will return all actions published by your app for a given action and a given user. For example, using a user access token:
https://graph.facebook.com/me/my_cooking_app:bake?access_token=...
Related
I try with no success to give read or write access to an existing user (Office 365) on a Sharepoint drive folder.
With Graph Explorer the URL is like :
https://graph.microsoft.com/v1.0/sites/{site id}/drive/items/{folder id}/permissions
I can get actual permissions with GET method, but with POST method and this body I've got Invalid Request :
{
"grantedToV2": {
"user": {
"id": "xxxxxxx",
"displayName": "xxx xxx"
}
},
"roles": [
"read"
]
}
I tried with the powershell SDK and the New-MgDriveItemPermission too with no success.
Any help is welcome !
In order to add permissions to an you will have to make a POST request to the below endpoint:
https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{folder-id}/invite
With the body containing all the info about the invitation request as the below example:
{
"requireSignIn": false,
"sendInvitation": false,
"roles": [ "read | write"],
"recipients": [
{
"email": "{email of the user}"
}
],
"message": "string"
}
If your request is succesful the response you will get back will be of the below format:
Status: 200
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(permission)",
"value": [
{
"#odata.type": "#microsoft.graph.permission",
"id": "<some id>",
"roles": [
"write"
],
"grantedTo": {
"user": {
"email": "<user>#<tenant>.onmicrosoft.com",
"id": "<some id>",
"displayName": "<user's display name>"
}
}
}
]
}
Below I will share with you the code snippet I got from Graph Explorer after creating a succesful request:
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var recipients = new List<DriveRecipient>()
{
new DriveRecipient
{
Email = "<user>#<tenant>.onmicrosoft.com"
}
};
var message = "Here's the file that we're collaborating on.";
var requireSignIn = true;
var sendInvitation = true;
var roles = new List<String>()
{
"write"
};
await graphClient.Sites["root"].Drive.Items["<folder-id>"]
.Invite(recipients,requireSignIn,roles,sendInvitation,message,null,null,null)
.Request()
.PostAsync();
Notes
You can find documentation about the endpoint here.
If you try to add permissions to a Folder that inherits its permission model from the document library, you should watch out because in some cases if the user is not a member of the site groups, MS Graph might invoke unique permissions on the folder.
by using Facebook Graph API I can fetch the conversations between users and my page. One of the returned conversations looks like this:
{
"message": "message content",
"from": {
"name": "My Page's Name",
"email": "198301820627381#facebook.com",
"id": "198301820627381",
},
"to": {
"data": [
{
"name": "John Doe",
"email": "396169264164870#facebook.com",
"id": "396169264164870",
}
]
},
"id": "m_mid.$cAADurJ0X8UhnJ3tfxVg9jYXJW5fp"
}
I see that I got the user's id field. How can I fetch this user's profile (first name, last name, profile pic) base on this field ? (or is there another way ?)
I followed the Graph API's User Reference but all I got are the user's id and name (which I already have from the returned conversation).
profile_pic only works for PSIDs (Messenger bot events), for ASIDs just use the picture field instead
I am using the "taggable_friends" api to get the list of all friends then uses the user ID (a string of 110 chars) to get user detailes like this:
FB.api('/' + gFriend.id , 'GET',{},
function(response) {
console.log("response",response)
});
In the result I get an error
(#803) Some of the aliases you requested do not exist: {The user Id I have submitted}
Did FB blocked user details API in version 2?
taggable_friends if for tagging only, you can´t use it for anything else and you don´t get a User ID. You only get a "tagging token" that can only be used for tagging. If you just want to create a "friend pic collage", you need to use /me/friends instead. Of course you will only get friends who authorized your app with the user_friends permission.
[from comments] I want to show friend pic collage
The taggable_friends endpoint does return URLs of the friend’s profile pictures already.
You get a data structure like this,
{
"data": [
{
"id": "AaKYNqeDaP…",
"name": "Foo Barski",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/…"
}
}
},
{
"id": "AaKBGEbAAvYU…",
"name": "Some One Else",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://scontent.xx.fbcdn.net/v/t1.0-1/p50x50/…"
}
}
},
So all you need to do is use those URLs provided in the picture structure.
I'm using the Facebook Graph API to fetch a public page feed. I created a basic application to get appId and secret. When I make a call to PUBLIC_PAGE_ID/feed I can retrieve the correct list of posts in JSON, but they are missing all the field I need, described in docs, and only have message, created_time and id:
{
"data": [
{
"message": "...",
"created_time": "2015-06-11T07:57:05+0000",
"id": "23X12XXXXXX9836_11XXXXXXXX610XXXX52"
},
...
Why all other data isn't there?
The response to your query: /id/feed is the default response. To access more data, you have to pass a fields parameter with the keyword of data you would like to retrieve.
For example: <id>/feed?fields=id,message,picture,shares
This will return:
{
"data": [
{
"id": "1234567890",
"message": "Message",
"picture": "http://fbcdn.com/xxxxxx.jpg",
"shares": {
"count": 0
}
}
}
What I could figure out is you should submit the app for review with at least one permission what your app still needs and then you will get back every data what you ask in the fields parameter.
I want to create app for get users' interaction with page. Each users like, comments, share specific page post.
I want to get count of total likes, comments and shares done by each user.
I used Graph API to return page
https://graph.facebook.com/PAGE_ID/feed?fields=id,likes,comments{from},shares
i got results similar to this.
{
"data": [
{
"id": "478412518924513_633895136709583",
"likes": {
"data": [
{
"id": "3696534343199936",
"name": "User Name"
},
{
"id": "576343349495810279",
"name": "User name"
}
],
},
"comments": {
"data": [
{
"from": {
"id": "154e3485900543",
"name": "user name"
},
"id": "633895096709587_633907896708307"
},
{
"from": {
"id": "10202701931494709",
"name": "User anme"
},
"id": "633895096709587_633899590042471"
}
],
}
},
How can i get how many likes,comments made by each user?
There are no endpoints you can get these counts from. This means that you have to aggregate the data yourself, namely
1) Iterating over the Page's Feed:
GET /{Page_ID}/feed?fields=id,created_time,likes{id},comments{from{id}},sharedposts&limit=200
and use the paging info to get the next results
See
https://developers.facebook.com/docs/graph-api/reference/v2.1/page/feed/#read
https://developers.facebook.com/docs/graph-api/reference/v2.1/post#edges
2) Aggregate the resulting data yourself in your application