Get more detail from Facebook Notifications? - facebook

I'm writing an app that gathers info from a users Facebook notifications. Using the Graph Explorer, I request:
me/notifications?include_read=true
and this returns a bunch of data. Each item is a notification item you would see when logging into Facebook. For example (ID/names changed slightly):
{
"id": "notif_630262196_168132987",
"from": {
"name": "John Bloggs",
"id": "822724665"
},
"to": {
"name": "Dermot Bloggs",
"id": "680265196"
},
"created_time": "2013-01-23T22:58:28+0000",
"updated_time": "2013-01-23T22:58:28+0000",
"title": "John Bloggs commented on your link: \"Goodbye Great Barrier Reef. Goodbye...\"",
"link": "http://www.facebook.com/<removed>/posts/330788937030559?comment_id=1702155",
"application": {
"name": "Links",
"id": "2309869772"
},
"unread": 0,
"object": null
}
The notification is in relation to a comment, but the "title:" field gets truncated if it is too long.
Is there a clean way I can programmatically access the comment directly, so I can get all the text, even if it is a 1000 character comment?
Thanks! :-)

You should be able to get the comment by parsing the link field and querying:
/330788937030559_1702155
or
/POSTID_COMMENTID
When I tested this on my account, I am getting a comments object in the returned data, with the full text of the comments. I've got most permissions enabled in my Graph API. I suspect adding read_stream to the permissions is what will give you this data.

You can avoid parsing! I've been doing a lot of experimentation with notifications and getting what I've called the 'source' object (the source object being the Facebook Graph Object from which the notification originates). Unfortunately, I can't find any documentation on how exactly this mechanism works, but if your app has been granted a lot of permissions, the "object" field which in the JSON you posted is null will actually be populated with the 'source object'. Instead of just "object" : null it will look like this:
"object": {
"id": "587140489_588632201147717",
"from": {
"name": "Dave Rodríguez",
"id": "587140489"
},
"message": ":D ",
"picture": "https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-prn1/632550_478955408819349_478954732152750_60483_1892_t.jpg",
"link": "https://www.facebook.com/photo.php?v=478954732152750",
"source": "http://video.ak.fbcdn.net/hvideo-ak-prn1/v/754708_478955348819355_1792301950_n.mp4?oh=c7295ccfc3773f24de931e4c29f512ce&oe=513F1728&__gda__=1363127340_9302c108824176369427a0b17491b800",
"name": "¡¡¡EL SECRETO DE LA CHANCLA!!!!",
"description": "EL SECRETO DE LAS MADRES, EL MÁS UTILIZADO EN TODAS LAS GENERACIONES, VÉALO USTED MISMO Y ((COMPARTA))!",
"properties": [
{
"name": "Length",
"text": "1:13"
}
],
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/587140489/posts/588632201147717"
},
{
"name": "Like",
"link": "https://www.facebook.com/587140489/posts/588632201147717"
}
],
"privacy": {
"value": ""
},
"type": "video",
"status_type": "shared_story",
"object_id": "478954732152750",
"application": {
"name": "Video",
"namespace": "video",
"id": "2392950137"
},
"created_time": "2013-03-10T20:45:20+0000",
"updated_time": "2013-03-10T20:45:20+0000",
"likes": {
"data": [
{
"name": "Adrian Guerra Cuenta Verificada",
"id": "674364748"
}
],
"count": 1
},
"comments": {
"count": 0
}
}
I hope somebody more knowledgeable than me can tell us exactly what permissions we need to see this field populated. I'd figure it out myself but there are so many permissions that brute-forcing the SUM(nCk(77,k),k,1,77)=151115727451828646838271 possible combinations of permissions would take a very long time.

Related

facebook graph api doesn't return the statuses i shared

I'm trying to fetch all my facebook timeline posts throw the facebook Graph API.
I'm playing with the Graph Explorer and have an access token with this permissions: (user_posts, read_stream) but when i call the endpoint "/posts" or "/feed" in the graph-api, the statues i shared (not i created) on my timeline (friends public status that i shared) didn't return.
this is a screenshot from my timeline
any idea?
If you share another POST - status then I dont think there is a way that will show up in your feed. It will show up under the user's feed who originally shared it, under posts and sharedposts
But if you share a link then it will show up under your feed as shared_story
Example from my feed
{
"data": [
{
"id": "XXXXXXXX",
"from": {
"id": "XXXXXXXX",
"name": "XXXXXXXX"
},
"story": "Vrashabh Irde shared a link.",
"story_tags": {
"0": [
{
"id": "XXXXXXXX",
"name": "XXXXXXXX",
"type": "user",
"offset": 0,
"length": 13
}
]
},
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQAvV7MyLsxFjRDc&w=130&h=130&url=https%3A%2F%2Ftctechcrunch2011.files.wordpress.com%2F2015%2F05%2Fdave-goldberg.jpg%3Fw%3D560%26h%3D292%26crop%3D1&cfs=1&sx=1&sy=0&sw=292&sh=292",
"link": "http://tcrn.ch/1GR0HU3",
"name": "Dave Goldberg, SurveyMonkey CEO, Dies Unexpectedly",
"caption": "tcrn.ch",
"description": "Silicon Valley and the wider world of technology are mourning the very sudden death of Dave Goldberg, a long time entrepreneur and investor, CEO of..",
"icon": "https://www.facebook.com/images/icons/post.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/XXXXXXXX/posts/XXXXXXXX"
},
{
"name": "Like",
"link": "https://www.facebook.com/XXXXXXXX/posts/XXXXXXXX"
}
],
"privacy": {
"value": "ALL_FRIENDS",
"description": "Your friends",
"friends": "",
"allow": "",
"deny": ""
},
"type": "link",
"status_type": "shared_story",
"created_time": "2015-05-03T14:45:09+0000",
"updated_time": "2015-05-03T14:45:09+0000",
"is_hidden": false,
"subscribed": true
}
This is from what I know, I dont see any documentation that says otherwise, good to have someone from Facebook comment here or you should probably raise a bug if this is not intended.

Getting high res photos from Facebook News Feed API

I am trying to get a high resolution photo from the post below in my news feed. I tried calling https://graph.facebook.com/v2.1/10154603506630195 using the object_id based on advice here (getting high resolution photos that were posted on a page wall/feed) but it doesn't seem to work, any help would be much appreciated :)
{
"id": "10154603665915195_10154603509055195",
"from": {
"id": "10154603665915195",
"name": "John Smith"
},
"message": "I've taken up queuing as a new hobby during my short time in England. Here we are outside a store that won't open for another half hour...",
"picture": "https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpf1/v/t34.0-12/s130x130/10699259_10154603507605195_419931109_n.jpg?oh=ff3ec0e772fea164bbd9d61e9ee9a4d0&oe=540E80D2&__gda__=1410242521_d3b2dc1c8f971610b07e0408cd62815b",
"link": "https://www.facebook.com/photo.php?fbid=10154603506630195&set=a.10150303996795195.555860.698310194&type=1&relevant_count=1",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yx/r/og8V99JVf8G.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/10154603665915195/posts/10154603509055195"
},
{
"name": "Like",
"link": "https://www.facebook.com/10154603665915195/posts/10154603509055195"
}
],
"privacy": {
"value": ""
},
"type": "photo",
"status_type": "added_photos",
"object_id": "10154603506630195",
"application": {
"name": "Facebook for iPhone",
"namespace": "fbiphone",
"id": "6628568379"
},
"created_time": "2014-09-07T10:40:03+0000",
"updated_time": "2014-09-07T10:40:03+0000",
"likes": {
"data": [
{
"id": "711243852300920",
"name": "Megumi Yoshida Atobe"
},
{
"id": "10152707756462594",
"name": "Emily Stokes-Rees"
},
{
"id": "10152741507272044",
"name": "Lina Kumamaru Sato"
}
],
"paging": {
"cursors": {
"after": "MTAxNTI3NDE1MDcyNzIwNDQ=",
"before": "NzExMjQzODUyMzAwOTIw"
}
}
}
}
If you are using the FB Graph API, ask for the full_picture field in your request:
FB.api('10153224297552834_10153268631032834?fields=full_picture', function (response) {
console.log(response.full_picture);
});
Try specifying the attachments field in your request.
/v2.2/<someId>/feed?fields=attachments
This will give you an 'attachments' field, with some media inside. You'll find there high res images.

Facebook Graph API posts not appearing for users of page, only admin

I created a page on facebook, and am using the graph api to make posts on the timeline. These post show up just fine for me as the admin, but for users the page is empty.
I verified with the graph api explorer. As an admin a GET of /NewsCrier/feed is filled with data.
As a non admin user the same request returns
{
"data": [ ]
}
Here is an example post from the response of my admin user, notice the privacy is set to public:
{
"id": "383422711781035_404880726301900",
"from": {
"category": "Community",
"name": "News Crier",
"id": "383422711781035"
},
"message": "This appears to be the DC shooter, Aaron Alexis",
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQD4wR0Y9UVbb4Js&w=154&h=154&url=http%3A%2F%2Fwww.justmugshots.com%2Fimg%2F814064%2Flg%2Faaron-alexis.jpg",
"link": "http://www.justmugshots.com/texas/fort-worth/814064",
"name": "Aaron Alexis, Arrested on 2010-09-04",
"caption": "www.justmugshots.com",
"description": "Aaron Alexis was arrested in Fort Worth, Texas on 2010-09-04. See the mugshot now.",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/383422711781035/posts/404880726301900"
},
{
"name": "Like",
"link": "https://www.facebook.com/383422711781035/posts/404880726301900"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "link",
"status_type": "shared_story",
"application": {
"name": "Reddit News Alerts",
"id": "693375074022011"
},
"created_time": "2013-09-16T19:36:07+0000",
"updated_time": "2013-09-16T19:36:07+0000"
}
The problem is that your Facebook app is in sandbox mode, as soon as you take the app from sandbox all the users will se the newly created posts ;)

Facebook Graph API: read posts by other apps on users wall

this is my first question on stackoverflow. Tried searching for this but none of the answers helped.
The problem is that im trying to use Graph API's read_stream permission to read the users stream. That works (mostly) but what i'm really instrested is posts from other apps like Endomondo and Runtastic (sports tracking stuff) -- but they dont show up at the graph explorer, only posts by the user himself.
What can i do?
You will need the proper OG action permission. For example, assuming Runtastic is a fitness action application, you will use user_actions.fitness permission and then call /me/fitness.runs
{
"data": [
{
"id": "10101174611725617",
"from": {
"name": "☃",
"id": "4"
},
"start_time": "2013-05-24T20:22:26+0000",
"end_time": "2013-05-24T20:22:26+0000",
"publish_time": "2013-05-24T20:22:26+0000",
"application": {
"name": "runtastic.com",
"namespace": "runtastic",
"id": "162918433202"
},
"data": {
"course": {
"id": "375109895929036",
"url": "http://www.runtastic.com/en/users/☃/sport-sessions/75329736",
"type": "fitness.course",
"title": "a 0h 0m 20s run"
}
},
"type": "fitness.runs",
"no_feed_story": false,
"likes": {
"count": 0,
"can_like": true,
"user_likes": false
},
"comments": {
"count": 0,
"can_comment": true,
"comment_order": "chronological"
}
},

Facebook 'Like' count on website is much lower than Facebook page

The "Like" count on my articles has been very low for the past few months. For example, an article has 190+ "Likes" on this Facebook page:
http://www.facebook.com/BatmanNewsCom/posts/282806528452384
and 321+ "Likes" on this Facebook page:
http://www.facebook.com/TDKRises/posts/208282902603624
But my website is only displaying 157 "Likes" for that article. This has been a problem with every article I've posted since around the middle of December. Any idea what could be wrong? Shouldn't they be in sync with the Facebook pages, and any other "Likes" elsewhere?
If anyone could help point me in the right direction, I'd really appreciate it. Thank you!
The 321+ "Likes" on https://www.facebook.com/TDKRises/posts/208282902603624 are "Likes" on that actual POST on facebook. The 157 "Likes" on this article http://batman-news.com/2012/02/09/heath-ledgers-joker-the-dark-knight-featured-in-oscars-ad/ are "Likes" for that URL. Facebook does not add "Likes" for a URL and "Likes" for a POST containing the said URL together; they are kept as two separate entities.
For instance, here's a link using FQL to query the link_stat table.
https://api.facebook.com/method/fql.query?query=SELECT+url%2C+normalized_url%2C+share_count%2C+like_count%2C+comment_count%2C+total_count%2C+commentsbox_count%2C+comments_fbid%2C+click_count+FROM+link_stat+WHERE+url%3D%22http://batman-news.com/2012/02/09/heath-ledgers-joker-the-dark-knight-featured-in-oscars-ad/%22&access_token=AAAAAAITEghMBAP3WZAm1IZCLto32KgEjjYbk5zCsRyZAf7YSSQyxBdqBXZAZBhqsKxZCpAnLUuOXV8lHzjmfuZCeJPRXv2GvBSmnENLVVlvhwZDZD`
And it returns this result:
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
<link_stat>
<url>
http://batman-news.com/2012/02/09/heath-ledgers-joker-the-dark-knight-featured-in-oscars-ad/
</url>
<normalized_url>
http://www.batman-news.com/2012/02/09/heath-ledgers-joker-the-dark-knight-featured-in-oscars-ad/
</normalized_url>
<share_count>104</share_count>
<like_count>53</like_count>
<comment_count>0</comment_count>
<total_count>157</total_count>
<commentsbox_count>0</commentsbox_count>
<comments_fbid>10150538028142844</comments_fbid>
<click_count>0</click_count>
</link_stat>
</fql_query_response>
Which shows the "Like" count you're getting on your page to be how many people "share" that URL + how many people like that URL.
Now if you do a Graph API query against the post ID, you can see that the like count does differ between URL and post.
https://graph.facebook.com/117326344965823_208282902603624
With a response of:
{
"id": "117326344965823_208282902603624",
"from": {
"name": "The Dark Knight Rises",
"category": "Movie",
"id": "117326344965823"
},
"story": "The Dark Knight Rises shared a link.",
"story_tags": {
"0": [
{
"id": 117326344965823,
"name": "The Dark Knight Rises",
"offset": 0,
"length": 21
}
]
},
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQDJ1A-Ok89RPwkn&w=90&h=90&url=http\u00253A\u00252F\u00252Fcdn.batman-news.com\u00252Fwp-content\u00252Fuploads\u00252F2012\u00252F02\u00252F846x476-175x165.jpg",
"link": "http://batman-news.com/2012/02/09/heath-ledgers-joker-the-dark-knight-featured-in-oscars-ad/",
"name": "Heath Ledger\u2019s \u2018The Dark Knight\u2019 Joker featured in Oscars ad",
"caption": "batman-news.com",
"description": "The Oscars air live on February 26th and today a new ad campaign was revealed. The ads all feature a reference to a great movie of the past. One of those great movies happens to be The Dark Knight...",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yD/r/aS8ecmYRys0.gif",
"type": "link",
"created_time": "2012-02-09T17:17:40+0000",
"updated_time": "2012-02-10T17:38:52+0000",
"shares": {
"count": 29
},
"likes": {
"data": [
{
"name": "Ahmed Yagoub",
"id": "1484476725"
},
{
"name": "Ryan Watkins",
"id": "725002161"
},
{
"name": "Buddy George Fonseca",
"id": "100001448442792"
},
{
"name": "S\u00edlvio Teixeira Leite",
"id": "100002240617284"
}
],
"count": 324
},
"comments": {
"data": [
{
"id": "117326344965823_208282902603624_786248",
"from": {
"name": "Chalerm Chaimongkol",
"id": "100002659449106"
},
"message": "You are the best, Heath Ledger. :)",
"created_time": "2012-02-09T17:20:59+0000",
"likes": 1
},
{
"id": "117326344965823_208282902603624_786250",
"from": {
"name": "Bradley Wayne Instance",
"id": "100003120853077"
},
"message": "Long Live Joker :)",
"created_time": "2012-02-09T17:21:08+0000",
"likes": 5
},
{
"id": "117326344965823_208282902603624_786259",
"from": {
"name": "Nilabh Singh",
"id": "531292994"
},
"message": "Greatest character ever in the history of Cinema.\nR.I.P Heath Andrew Ledger.\nYou were a legend.",
"created_time": "2012-02-09T17:22:15+0000",
"likes": 10
},
{
"id": "117326344965823_208282902603624_786291",
"from": {
"name": "Camie Chaos",
"id": "517844186"
},
"message": "\u003C3\u003C3\u003C3",
"created_time": "2012-02-09T17:25:45+0000"
},
{
"id": "117326344965823_208282902603624_786313",
"from": {
"name": "Anand Tiwari",
"id": "1321947394"
},
"message": "you are a legend!!!",
"created_time": "2012-02-09T17:28:51+0000"
},
{
"id": "117326344965823_208282902603624_786314",
"from": {
"name": "Manoj Biswal",
"id": "100001010999210"
},
"message": "indeed great character",
"created_time": "2012-02-09T17:29:13+0000",
"likes": 1
},
{
"id": "117326344965823_208282902603624_786327",
"from": {
"name": "Lee Duller",
"id": "100003188571395"
},
"message": "Love that joker!",
"created_time": "2012-02-09T17:36:30+0000",
"likes": 2
},
{
"id": "117326344965823_208282902603624_786329",
"from": {
"name": "Ben Cribbett",
"id": "633801171"
},
"message": "was a amazing joker, i have him tattoo'd on my arm R.I.P. :(",
"created_time": "2012-02-09T17:37:19+0000",
"likes": 2
},
{
"id": "117326344965823_208282902603624_786346",
"from": {
"name": "Eric Jones",
"id": "1343067459"
},
"message": "GLAD he won, but screw the Oscars. TDK should've been up for many more awards, Ledger should have won BEST ACTOR (not supporting as anyone who has actually seen the movie knows it is as centered around him as much as Wayne/Batman), and Harry Potter & Xmen: First Class are snubbed this year?!?\n\nin a year of HIGHLY overrated & underwhelming films? what a joke & w/out a great punchline like The Joker would deliver.\n\nwill find anything better to do than waste time on this stupid awards show this year. hell, i missed most of the SAG Awards and they're way better than the Oscars.\n\nbut First Class was one of the best of the year, bar none, and topped a good summer of VERY good blockbusters (minus Green Lantern, of course). to be totally snubbed & disrespected just shows what a bunch of geriatric douchebag assclowns The Academy is full of.",
"created_time": "2012-02-09T17:45:32+0000",
"likes": 2
},
{
"id": "117326344965823_208282902603624_786381",
"from": {
"name": "Boris Kopp",
"id": "100003049418181"
},
"message": "\"You changed everything.\" Thats true, Heath. You really changed everything with this once on a lifetime performance in The Dark Knight. In this role and many others, you stay alive in our hearts.",
"created_time": "2012-02-09T17:54:59+0000",
"likes": 2
},
{
"id": "117326344965823_208282902603624_786383",
"from": {
"name": "Ninad Naik",
"id": "100003125720497"
},
"message": "Why so serious...???\r\nLets put some smile on your face....:)\r\nHail Joker....!!!!\r\n",
"created_time": "2012-02-09T17:56:08+0000",
"likes": 2
},
{
"id": "117326344965823_208282902603624_786395",
"from": {
"name": "Taylan Erdem",
"id": "100001437162326"
},
"message": "the dark knight is old it is the dark knight rises!!!",
"created_time": "2012-02-09T18:00:09+0000"
},
{
"id": "117326344965823_208282902603624_786510",
"from": {
"name": "Nerd Rawk",
"category": "Entertainer",
"id": "259582000764594"
},
"message": "We discuss comic books in our latest podcast! http://nerd-rawk.podomatic.com/entry/2012-02-07T21_09_20-08_00",
"created_time": "2012-02-09T18:25:58+0000"
},
{
"id": "117326344965823_208282902603624_786512",
"from": {
"name": "Nisargh Ny S",
"id": "100000537517253"
},
"message": "hope jhonny depp replaces joker..",
"created_time": "2012-02-09T18:26:29+0000"
},
{
"id": "117326344965823_208282902603624_786532",
"from": {
"name": "Sergio Rossell Reyes",
"id": "1038781683"
},
"message": "wow, seems like the oscar's producers really want to make people watch this year's show.",
"created_time": "2012-02-09T18:33:36+0000"
},
{
"id": "117326344965823_208282902603624_786560",
"from": {
"name": "Andrew Kilian",
"id": "625429396"
},
"message": "Borderline bad taste.",
"created_time": "2012-02-09T18:40:29+0000"
},
{
"id": "117326344965823_208282902603624_786780",
"from": {
"name": "Peter Ike Amadi",
"id": "1617233525"
},
"message": "Heath, you changed things at the Oscars. Forever. You see some men aren't looking for anything logical, they can't be bought, bullied, reasoned or negotiated with. Some men just want to watch the Oscars burn...",
"created_time": "2012-02-09T19:49:05+0000",
"likes": 5
},
{
"id": "117326344965823_208282902603624_786844",
"from": {
"name": "Luke Hobbs",
"id": "1123606586"
},
"message": "and in 2013 tom hardy will win an oscar for his amazing performance in the dark knight rises as bane",
"created_time": "2012-02-09T20:11:48+0000",
"likes": 4
},
{
"id": "117326344965823_208282902603624_787859",
"from": {
"name": "Jackson Krista",
"id": "100000650880066"
},
"message": "http://www.youtube.com/watch?v=iyNqmiX_Xl8",
"created_time": "2012-02-10T02:32:41+0000"
},
{
"id": "117326344965823_208282902603624_790194",
"from": {
"name": "Kishan Herchandani",
"id": "1849953622"
},
"message": "he deserves that",
"created_time": "2012-02-10T17:38:52+0000",
"likes": 2
}
],
"count": 20
}
}
Showing the likes to be 324 for the post. Hope that helps.
Christopher, I agree that up until fairly recently the Likes that a url got when shared as a link on a wall post used to increase the count shown on the Like button. I started a thread about this on the Facebook specific Stack Overflow here: http://facebook.stackoverflow.com/questions/8944567/likes-on-link-wall-post-not-counting-on-like-button-plugin
Please let me know if you figure out anything else.