How to check if the facebook post is commentable - facebook

I am fetching the Facebook news feeds through API. User can comment on a post from website. but some posts doesnot allow the comment like Like Stories, add friend stories, change profile pic stories etc
How I can check that if the post allow the comment or not

The actions property of the post when you retrieve it from the API will show if the current (whose access_token you're using) user can like or comment on the post, e.g.
/20531316728_167191526758558
Contains:
{
"id": "20531316728_167191526758558",
"from": {
"name": "Facebook",
"category": "Product/service",
"id": "20531316728"
},
"message": "Find your polling place on Facebook at http://bit.ly/Fbppl and then watch the nation vote in real time.",
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQCD6BNbTzxhmwEq&w=90&h=90&url=https%3A%2F%2Fs3.amazonaws.com%2FFacebookHackers-production%2Fissue4_data%2Fissue4_fb_og.png",
"link": "http://www.facebookstories.com/vote",
"name": "America Votes 2012",
"caption": "www.facebookstories.com",
"description": "Watch the nation vote in real time.",
"icon": "https://s-static.ak.facebook.com/rsrc.php/v2/yN/x/aS8ecmYRys0.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/20531316728/posts/167191526758558"
},
{
"name": "Like",
"link": "https://www.facebook.com/20531316728/posts/167191526758558"
}
],
// (and more properties which aren't relevant

Related

How can I get all photos in one post in a page using Graph API?

For example this graph
https://graph.facebook.com/audi/posts?access_token=[ACCESS TOKEN]&fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&since=2016-10-14T17:54:17+0000&limit=1
will give you this result(after replace ACCESS TOKEN with your access token ) :
{
"data": [
{
"id": "96585976469_10153772437221470",
"message": "Take a night tour of Capitol Hill with the #AudiRS7. #AudiDuel",
"picture": "https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/14680669_10153772435521470_6025374941796908984_n.jpg?oh=3654e74f79914c9bb0fa596ce8434c46&oe=589E82B4",
"link": "https://www.facebook.com/audi/photos/a.101113351469.101662.96585976469/10153772435521470/?type=3",
"name": "Photos from Audi USA's post",
"type": "photo",
"icon": "https://www.facebook.com/images/icons/photo.gif",
"created_time": "2016-10-14T17:54:17+0000",
"from": {
"name": "Audi USA",
"id": "96585976469"
},
"object_id": "10153772435521470"
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.5/96585976469/posts?fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=1&since=1476467657&access_token=[ACCESS TOKEN]&__paging_token=[ACCESS TOKEN]&__previous=1",
"next": "https://graph.facebook.com/v2.5/96585976469/posts?fields=id,message,picture,link,name,description,type,icon,created_time,from,object_id&limit=1&since=2016-10-14T17\u00253A54\u00253A17+0000&access_token=[ACCESS TOKEN]&until=1476467657&__paging_token=[ACCESS TOKEN]"
}
}
and this is the link of the post
https://www.facebook.com/audi/posts/10153772437221470
it gave me just the first one photo but I need all photos in this post
attachments is the field you are looking for.
(Seems not officially documented, perhaps because those aggregate posts are special. But Graph API Explorer suggests it as one of the available fields.)

Sharing Spotify link to Facebook and retrieving the link from graph api?

I have posted a link to a spotify track on my facebook account - something like this:
http://open.spotify.com/track/0aXxt38KBHHSmwNsHtIonU
Facebook appears to pick up the link (I get the track image and other data appearing in my feed)
But when I make a request to it via /me/feed in the graph api, there's no link or data relating to the track itself. All I get back is object that looks like this:
..{
"id": "{{some_id}}",
"from": {
"id": "{{my_id}}",
"name": "Si Davies"
},
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/y0/r/nAApRnfWfNW.gif",
"actions": [
{
"name": "Comment",
"link": "{{link to the post}}"
},
{
"name": "Like",
"link": "{{link to the post}}"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "link",
"status_type": "shared_story",
"created_time": "2014-06-17T02:17:06+0000",
"updated_time": "2014-06-17T02:17:06+0000"
}...
Which isn't much use to me - I've tried specifying a link field with something like me/feed?fields=link and also mucked around granting various permissions with little or no effect.. how can I see what spotify track was added to my feed from the graph api?
Spotify seems to use the global music.listens Facebook OpenGraph action. Have a look at https://developers.facebook.com/docs/opengraph/music/
You should be able to retrieve your data by issuing
GET /me/music.listens
according to the docs at https://developers.facebook.com/docs/reference/opengraph/action-type/music.listens#read Remember to grant the user_actions.music permission to be able to read the data (https://developers.facebook.com/docs/facebook-login/permissions/v2.0#reference-opengraph)

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

How do you retrieve the "Place" field of a Facebook Graph Post object?

I am trying to retrieve the "Place" field of a Facebook Graph Post object from a Facebook friend. After obtaining an access token with the friends_status and read_stream permissions, I request from the Graph API like so:
http://graph.facebook.com/[user_id]_[post_id]
What is returned are some of the fields described in the Graph API docs for Post:
{
"id": "1164358582_2458311174854",
"from": {
"name": "Joe Blo",
"id": "1164358582"
},
"message": "Is pretty bummed today",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
},
{
"name": "Like",
"link": "http://www.facebook.com/1164358582/posts/2458311174854"
}
],
"type": "status",
"application": {
"name": "Facebook for Android",
"id": "350685531721"
},
"created_time": "2011-11-20T03:23:04+0000",
"updated_time": "2011-11-20T12:12:49+0000",
"comments": {
"data": [
{
"id": "1164358582_2458311174852_2962531",
"from": {
"name": "Sue Candy",
"id": "1056617421"
},
"message": "OMG I'm so sorry!!!",
"created_time": "2011-11-20T03:25:06+0000"
}
],
"count": 1
}
}
This is all fine and dandy, except for the fact that when I see this Post within my Facebook stream, it also shows a location accompanying the post:
9 hours ago near El Reno, OK
I expected the El Reno, OK Place object returned as a field within this Post, but I don't see it.
In the Facebook Graph API Explorer, I've tried enabling almost every permission and I am not seeing any difference in the response (no "Place" field returned). Am I going about this incorrectly?
Not 100% sure but I think you can only get the "place" info if it is of type "checkin". I totally get where you are coming from, I wondered about that myself.
https://developers.facebook.com/tools/
Try the Graph API Explorer Tool if you haven't already looked at it.

How to get "newly added photos to an album" in facebook news feed using Graph Api

I am getting facebook news feed using
News feed: https://graph.facebook.com/me/home?access_token=MyAccessToken
I am getting all news feed object.But in news feeds object with type "photo",
I am getting only last added picture url (If user is added some photos to that album).
But how to get news feeds like "Jack added 3 new photos to the album MyApp Photos."
I want to get 3 photos in that album , if user added any photos to an album. I googled a lot.
Please help me. Thanks in advance.
Alright - this is a little bit hacky but I can't see any otherway. In your news feed you will see an item along the lines of:
{
"id": "123456789_3453453455345334",
"from": {
"name": "A Friend",
"id": "123456789"
},
"to": {
"data": [
{
"name": "A Friend",
"id": "123456789"
}
]
},
"picture": "PICTURE_URL",
"link": "http://www.facebook.com/photo.php?fbid=3453453455345334&set=a.10151233554845639.123456.123456789&type=1",
"name": "Mobile Uploads",
"caption": "10 new photos",
"icon": "ICON_URL",
"type": "photo",
"object_id": "3453453455345334",
"application": {
"name": "Facebook for iPhone",
"id": "6628568379"
},
"created_time": "2000-06-29T19:56:50+0000",
"updated_time": "2001-06-29T19:56:50+0000"
},
The key in there is the link url, which contains:
set=a.10151233554845639.123456.123456789
The first number, after the a, appears to be the album id. We can therefore get the photos from the album by querying:
https://graph.facebook.com/10151233554845345/photos?access_token=ACCESS_TOKEN
If you share a photo that already exists on Facebook then it appears with an extra property called properties:
"properties": [
{
"name": "By",
"text": "A Friend",
"href": "http://www.facebook.com/a.friend"
}
],
If you share a photo on your wall this is actually an upload and so will not include the properties property