How to retrive action ID with object ID and User ID? (Open Graph Custom Action) - facebook

So the situation is such:
I want the user to perform an (unique) action on my page. I do this through the presentation of an interface and a set of objects on my page. Works flawlessly.
But in order to present a complete user interface I must also give the option to delete the performed action, so I must know if a user has already interacted with a certain object.
Now could I run through all the objects, the user has interacted with and check, if the asked object is in there, but this way is not very resource savvy, when the user has interacted with a lot of items.
So the basic question is: Is there an API method, where I can look whether this user has already an action with the given object?
Thanks for your help!

https://graph.facebook.com/me/APP_NAMESPACE:ACTION_NAME
This will give you a list of all the actions of type ACTION_NAME that the current user has performed.
In the list you'll also find the connected objects.
Example:
https://graph.facebook.com/me/polarprint_forum:ask
{
"data": [
{
"id": "10150663311283415",
"from": {
"id": "549348414",
"name": "Joakim Syk"
},
"start_time": "2012-03-08T13:10:44+0000",
"end_time": "2012-03-08T13:10:44+0000",
"publish_time": "2012-03-08T13:10:44+0000",
"application": {
"id": "346637838687298",
"name": "Polar Print Forum"
},
"data": {
"question": {
"id": "10150604589861693",
"url": "http://www.polarprint.se/facebook_thread_tab/946/k\u0025C3\u0025A4ppteknik_vid_kullersten.html",
"type": "polarprint_forum:question",
"title": "käppteknik vid kullersten"
}
},
"likes": {
"count": 0
},
"comments": {
"count": 0
}
}
],
"paging": {
"next": "https://graph.facebook.com/me/polarprint_forum:ask?format=json&offset=25&limit=25"
}
}
A more efficient approach would probably be to store this information on your end when creating the actions.

Related

Combining multiple facebook page reviews feeds in one call

How is it possible that I can add another access token to this call that references the second id I would like to retrieve reviews from.
In all other instances like posts, photos etc this would work but because you are required to have a page access token to retrieve the data for reviews I'm not sure how to construct the url to make the call. Is it possible?
https://graph.facebook.com/ratings?ids=slickremix,reformavi&field=rating&limit=5&access_token=EAAP9hArvboQBAN5...
That call returns something like this, as you can see the second id reformavi is not returning data.
{
"slickremix": {
"data": [
{
"created_time": "2016-10-13T09:22:02+0000",
"reviewer": {
"name": "Jens Kranen",
"id": "10211267740634296"
},
"rating": 5,
"review_text": "Fantastic customer support. Very quick response. Spencer could identify the problem within minutes and gave great advice.\nThank you"
},
{
"created_time": "2016-10-07T14:22:19+0000",
"reviewer": {
"name": "Marc McHale",
"id": "10157614348555341"
}
"rating": 5,
"review_text": "I purchased the Facebook Reviews plugin for a client website and both my client and I are very happy with the appearance and functionality! Plus, the customer service was outstanding!"
}
],
"paging": {
"cursors": {
"before": "MTM4MjkwMTM4ODoxMTg3OTA3NTE1MjU4ODQZD",
"after": "MTI1MTQ3Njk2NToxMTg3OTA3NTE1MjU4ODQZD"
},
"next": "https://graph.facebook.com/v2.7/118790751525884/ratings?access_token=EAAP9hArvboQBAN5HpnbA5m87qC7poAAqB0YS47zxBCBmCfVRcqCC7zX1XDNCv6cSe3KFnMtPVysUms0MuXLxWfv8D9McMwzvD2HWWd0IO6FOZC6ogvcta8FWZBR0vUA9HCZAdqdB53fyUB26XLb76ORLspiPg3Hzb4Pn5RTjwZDZD&pretty=1&limit=5&after=MTI1MTQ3Njk2NToxMTg3OTA3NTE1MjU4ODQZD"
}
},
"reformavi": {
"data": [
]
}
}

How to get count of each fan's likes, comments for posts on Facebook page using Graph API

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

Access social readers' posts in a facebook App

How can a facebook app, have access to a social reader's post in the feed? For example, I want to have access to Washington Post's social reader post (when someone else reads an article there and it gets shown up in my news feed) from an app that I am writing. Is it possible to do so, using FQL?
It's easily available in the Graph API (i'll check if it's in FQL)
Basically, either way you'll need to request the user_actions.reads permission from your users. (NB: not user_actions:reads which would be for an app whose namespace is 'reads', for news, music and video apps using the build-in actions there's a special scope)
Then, for the Graph API, just make a call to /USER_ID/news.reads - the response includes the recently read articles from all apps using the built-in 'read' action, example response for my account below:
{
"data": [
{
"id": "REMOVED_ID",
"from": {
"id": "REMOVED_MY_USER_ID",
"name": "REMOVED_MY_NAME"
},
"start_time": "2012-05-10T00:05:10+0000",
"end_time": "2012-05-10T00:05:10+0000",
"publish_time": "2012-05-10T00:05:10+0000",
"application": {
"id": "235586169789578",
"name": "The Independent"
},
"data": {
"article": {
"id": "10150697347986736",
"url": "http://www.independent.co.uk/life-style/food-and-drink/features/the-10-best-scotch-whiskies-1488408.html",
"type": "article",
"title": "The 10 Best Scotch Whiskies"
}
},
"likes": {
"count": 0
},
"comments": {
"count": 0
}
},
.... //more articles

Is there a way to get recent video.watches activity for a specific app?

I want to give the user a UI to delete activity. I'm aware of it, but I'd rather not use the Activity social plugin. I know that it is possible to get activity using Graph API:
me/video.watches
example response:
{ "data": [ {
"id": "10101573590568760",
"from": {
"id": "123546",
"name": "John Doe"
},
"start_time": "2012-02-01T18:53:34+0000",
"end_time": "2012-02-01T18:53:34+0000",
"publish_time": "2012-02-01T18:53:34+0000",
"application": {
"id": "123456789123",
"name": "test_app"
},
"data": {
"movie": {
"id": "123456789123456789",
"url": "http://example.com/movie/My-Movie-Title",
"type": "video.movie",
"title": "My Movie Title"
}
}, "likes": {
"count": 0
}, "comments": {
"count": 0
}
}
However, for global action types, this may return other apps as well. I am only interested in my app specifically. Is there a way to limit returned data to my app only?
Appears that video.watches only returns activity items for the current app.

Facebook Graph API - Get like count on page/group photos

I've been testing graph API and ran into a problem. How can I get like count from photos of a page/group?
I'm administrator/creator of a group. When entering in https://developers.facebook.com/tools/explorer/ certain photo ID from that group it brings almost all data, even comments, but not the like count. For like part it needs (according to docs) access token despite the fact that anyone can access that info.
How to get access token of my page/group with required permissions and how to use it to get info I need?
If possible I would like to get JSON from a single address if it is possible.
This is possible with a page (even without an access token!) and here's how:
Visit the page on the graph
Get the page's id by going to the page's url:
https://www.facebook.com/pages/platform/19292868552
The number on the end of the URL is the page's id. Take that id and use it with the graph explorer (here) or just visit it directly.
Visit the page's albums
Now appending albums to that url will give you all the albums the page has, including wall photos:
https://graph.facebook.com/19292868552/albums
The output looks like this:
{
"data": [
{
"id": "10150160810478553",
"from": {
"name": "Facebook Platform",
"category": "Product/service",
"id": "19292868552"
},
"name": "Bringing Operation Developer Love to Europe",
"description": "Blog post: http://developers.facebook.com/blog/post/479\n\nVideos and presentations uploaded here: http://developers.facebook.com/videos/",
"location": "Berlin, Paris, London",
"link": "https://www.facebook.com/album.php?fbid=10150160810478553&id=19292868552&aid=285301",
"cover_photo": "10150160811078553",
"count": 32,
"type": "normal",
"created_time": "2011-04-06T23:05:44+0000",
"updated_time": "2011-04-06T23:33:20+0000",
"comments": {
..... etc ....
Selecting an album
For each object in the data array there is an id and a name. Using these two fields you can select the album that contains the photos you want. The first album in this result is "Bringing Operation Developer Love to Europe". Lets look at this albums photos.
Seeing Photos
If you've followed the answer up to this point the next step should be fairly obvious. Use the id for the album you want and append photos to the graph url:
https://graph.facebook.com/10150160810478553/photos
Seeing a Photo's likes
Much like selecting an album, simply use an id in the output of the above step and append likes to the url to see a photos likes:
https://graph.facebook.com/10150160813853553/likes
Output:
{
"data": [
{
"id": "1163036945",
"name": "Aditya Pn"
},
{
"id": "1555885347",
"name": "Nadin M\u00f6ller"
},
{
"id": "100001643068103",
"name": "Umut Ayg\u00fcn"
},
{
"id": "100000165334510",
"name": "Alessandra Milfont"
},
{
"id": "100001472353494",
"name": "Sayer Mohammad Naz"
},
{
"id": "1051008973",
"name": "Jenson Daniel Chambi"
},
{
"id": "100000233515895",
"name": "Ruby Atiga"
},
Using this output you can simply count the number of entries in the data array to get the like count.
Note that all of this is possible from using the graph explorer by clicking on ids in the output box and the connections sidebar (except for the last /likes connection, which will hopefully be added soon. I hope this helps. Also, you do not need an access token to do any of this because pages are public. Hope this helps!
You can get the comments/likes count without having to paginate through all likes by using the fields parameter in combination with likes.limit(1).summary(true). For example, a search api query for pizza below will give you all public posts and their likes count summarized:
https://graph.facebook.com/search?q=pizza&type=post&fields=id,name,likes.limit(1).summary(true)
results (truncated):
{
"data": [
{
"id": "47883936273_659693910762305",
"name": "Instagram",
"created_time": "2014-02-16T01:15:29+0000",
"likes": {
"data": [
{
"id": "100002243084532",
"name": "Yvette Martin"
}
],
"paging": {
"cursors": {
"after": "MTAwMDAyMjQzMDg0NTMy",
"before": "MTAwMDAyMjQzMDg0NTMy"
},
"next": "https://graph.facebook.com/47883936273_659693910762305/likes?limit=1&summary=1&after=MTAwMDAyMjQzMDg0NTMy"
},
"summary": {
"total_count": 13682
}
}
},
{
"id": "136336876521150_314001148754721",
"name": "Pizza Box Turns into Plates & Storage Unit!",
"created_time": "2014-02-15T21:20:00+0000",
"likes": {
"data": [
{
"id": "100005373008864",
"name": "Liliana Campoli"
}
],
"paging": {
"cursors": {
"after": "MTAwMDA1MzczMDA4ODY0",
"before": "MTAwMDA1MzczMDA4ODY0"
},
"next": "https://graph.facebook.com/136336876521150_314001148754721/likes?limit=1&summary=1&after=MTAwMDA1MzczMDA4ODY0"
},
"summary": {
"total_count": 2792
}
}
}
/me/feed returns a LIKES field
I used a solution where I simply find the number of items in the array which display LIKES
Object.keys(item.likes.data).length
This returns the "length" of an object -- which is equal to the number of likes.
http://graph.facebook.com/223766074374957
there is a likes property in the response
{
"name": "Bejeweled Blitz",
"is_published": true,
"website": "https://apps.facebook.com/bejeweledblitz/",
"username": "bejeweledblitz",
"products": "Bejeweled Blitz\nBejeweled\nPlants vs. Zombies\nPeggle\nZuma\nChuzzle\nBookworm Adventures\n \nFor a complete list, please visit www.popcap.com\n ",
"about": "We're the award-winning hit, Bejeweled Blitz! The lightning-fast puzzle game where you have just 60-seconds to match as many gems as you can! Start Blitzing now!",
"general_info": "Speed is the name of the game in Bejeweled Blitz! Bejeweled Blitz is a speedier take on the classic Bejeweled match-3 gem game mechanic. Your goal is to make as many matches as you can in 60-seconds to really make your score soar! But you won't be going it alone! There are special ways to enhance your Bejeweled Blitz game - like Boosts (power-ups like Scrambler, which moves all the gems around the board or +5 seconds, to add 5 seconds more gem-matching time!) and the popular, Rare Gems. Rare Gems are like extra-special power-ups that can REALLY take your game to the next level!",
"talking_about_count": 22487,
"category": "App page",
"id": "223766074374957",
"link": "https://www.facebook.com/bejeweledblitz",
"likes": 5796324,
"cover": {
"cover_id": 383412771743619,
"source": "http://sphotos-c.ak.fbcdn.net/hphotos-ak-ash4/s720x720/417018_383412771743619_1056862875_n.jpg",
"offset_y": 0
}
}