Facebook Page Comments Using Graph API & Stream Filter - facebook

I have my site working using the Facebook Comments Plugin as you can see here http://www.amanzitravel.com/namibia-wildlife-sanctuary
I am trying to use the Graph API to retrieve the comments so they are on the page in a form that is beneficial for SEO (as outlined here https://developers.facebook.com/docs/plugins/comments/).
Ideally I want to see not only all comments, but replies to comments. According to the API (https://developers.facebook.com/docs/graph-api/reference/v2.0/object/comments) using filter=stream should do the trick.
However when I do that I only get the two most recent comments e.g. https://graph.facebook.com/comments/?ids=http://www.amanzitravel.com/namibia-wildlife-sanctuary&filter=stream as opposed to the default https://graph.facebook.com/comments/?ids=http://www.amanzitravel.com/namibia-wildlife-sanctuary where I get all the top level comments but none of the replies.
EDIT: Further to this, it appears to update itself some time later, but when another reply is added it goes back to displaying a subset of all the comments for a period of time. Its unfortunate because it means I can't rely on this to be accurate.
Is there anyway I can make this work properly?

Related

How to get responses and comment attachments with Graph API

I am working on capturing Facebook page, event and group feeds with the Graph API. It's for a research project for my master studies. With these lines in the Graph API Explorer
{page-id}/feed?fields=from,message,likes,comments,attachments
I can capture the most I need. But the responses on comments and the attachments in comments (like when someone uses images in his or her comment) are still missing. How can I get them with the Graph API Explorer? It would be greet if I can get them within the whole context of the feed, not just when typing in the specific comment-id in the Graph API Explorer. Is there any way to get the needed data?
As https://developers.facebook.com/docs/graph-api/reference/v2.7/object/comments#read explains, it depends on the filter modifier whether you only get the top-level comments (toplevel, default), or all comments including replies (stream)
So if you modify your request as follows, you will get comments and replies on them in one go:
{page-id}/feed?fields=from,message,likes,comments.filter(stream),attachments
^^^^^^^^^^^^^^^
But that will give you all comments on the same level in the data structure, so you won’t know which are replies – so you might want to request the parent property as well; for replies that holds the id of the parent comment. With
comments.filter(stream){parent,from,message,created_time}
you will also get the parent for comments that have one. (Once you’re asking for a specific field, you need to ask for the rest of the fields you want as well.)

Get old Facebook posts from public FB page

For a university research project I need to view some old posts on public Facebook pages from a specific date range (January 22-31 2014.) I was planning just to copy and paste each post but I have run into a problem with some of the pages that generate a very high volume of posts. Facebook will not display past a certain date. Even with scrolling down, at a certain point the posts stop displaying (this is true by month, so it jumps from January 25 directly to December 31 for example).
Here are the pages I am interested in:
https://www.facebook.com/Syrian.Revolution
https://www.facebook.com/Syrian.Truth
I have read about Facebook's Graph API but have had some trouble using it (I don't have a developer's background.) Also the posts are mostly in Arabic so that may be a problem.
I just need the pages' posts, not the comments sections.
Thanks anyone so much for your help, it is very appreciated.
Really depends on what language/environment you're using. As a simplest case, you can just use Graph API Explorer (https://developers.facebook.com/tools/explorer) and make a call:
{{page_id}}/posts
There are a lot of ways you can improve this call for your benefit. For example, you can use a limit parameter to increase the default number of results it retruns.
{{page_id}}/posts?limit=200
By default, this returns a lot of fields, you can limit the fields.
{{page_id}}/posts?limit=200&fields=id,message,created_time
You can visit https://developers.facebook.com/docs/graph-api/reference/page/feed/ to find out which fields are supported.
In order to get results during a certain time-range, you can use the created_time field to determine if a post belongs to a certain time interval.

Facebook Graph API Event Paging not working?

I am trying to access past event via Facebook's Graph API.
I am getting current events just right (the one I attended last month and the one in the future) with
https://graph.facebook.com/me/events?access_token=[ACCESS_TOKEN]
However, the paging components "previous" and "next" don't really work, "previous" actually points to a future event that's already been listed in "me/events". While "next" just returns an empty "data" struct.
I also tried "since" with different previous timestamps (such as "me/events?since=1304238280") and it didn't work, it will always return the events that are the same as the ones returned by "me/events". But I definitely have many more past events when I visit
https://www.facebook.com/events/past/
Am I not using the graph API correctly or what? I also noticed there are quite a few questions regarding Graph API's paging problem but there doesn't seem to be a definitive answer yet.
Any info/suggestion/reference would be greatly appreciated!
From what I've seen, it appears that about two weeks after an event ends, Facebook moves the event data out of the events table and into another one that isn't exposed via the API. The internal Facebook servers have access to this table, so you can see past events from within the Facebook webapp.
I'm assuming this is a privacy thing.
try to add the "before" query string with the ID of the first event ex:https://graph.facebook.com/me/events?&before=388551911259170.
you can refer to the following link: https://developers.facebook.com/docs/reference/api/pagination/

How to access links provided on one's timeline?

I would like to have access to the links one shared on their timeline.
Using the API Graph Explorer, I see there is a way to access "links". However, it returns empty data. I believe that this might have been used when posting links in FB was done in a special way, different than posting "usual" status.
Then, I thought, I should probably get all the stream and filter the data for links. But at that point, I'm a little confused:
There are THREE different actions that seem to provide the very same data:
- https://graph.facebook.com/me/feed
- .../me/posts
- .../me/statuses
Are they actually all the same?
In addition, all seem to provide me information that is not up to date, but is true for some point in the near past. Moreover, I would like to know how I can get the relevant data from the beginning of the FB usage, or at least, for a given period of time.
Do an HTTP Get to me/links to get the most recent links the user has shared.
To limit it to a timeframe, you can do me/links?since=YYY&until=ZZZ.
Or you can use the paging object to get the previous and next url to use to get that other page of data.

Facebook Graph API SEO Comments and Profanity Filter

I'm trying to integrate the Facebook comments left on our site in a way in which the content can be crawled by search engines and also for people (although I highly doubt there will be many) who don't have Javascript enabled on their browser.
Currently our Facebook comments are displayed via the use of the Facebook comment social plugin (using the <fb:comments href="MY_URL" num_posts="50" width="665"></fb:comments> tag). This ends up rendering an iFrame (which are mostly ignored by search engine crawlers) so the plan is to render this information and format it with basic HTML. To do this, the comments are pulled using the Graph API - this is then only be displayed to crawlers and people with Javascript disabled.
This all works nicely using the Graph API call (https://graph.facebook.com/comments/?ids=MY_URL), parsing the JSON result and displaying it on the page. The problem is that the <fb:comments> approach filters our results based on a blacklist we have set up on one of our Facebook Apps. The AppId with the relevant blacklist is stored on the page using metadata (<meta property="fb:app_id" content="APP_ID"/>) which the <fb:comments> control obviously must somehow use to filter the comments.
The problem is the Graph API method does not filter any results as I guess no blacklist (or App Id containing a blacklist) is specified. Does anyone know how to specify a Facebook App ID to the API call URL or of another way to not fetch commnents back that violate the terms of the blacklist?
On a side note, I know the debate about filtering content in comments rages on but it is a management decision to implement the blacklist, and one that I have no influence in changing - just incase anyone felt the need to explain the reasons why content filtering is or isn't a good idea!
Any thoughts on a solution?
Unfortunately there's no way to access a filtered list of comments using the API - it might be a reasonably request to have this in the API - you should file a wishlist item in Facebook's bug tracker
Otherwise, the only solution I can think of is to implement your own filter on your side when retrieving and displaying the comments from the API.
According to the Comments plugin documentation the filter on Facebook's side is implemented as a simple substring match, so it should be trivial to implement.
A fairly simple regular expression match should be able to check each comment against a relatively long list quickly.
(Unfortunately, the tradeoff here is that implementing a filter is easy, but you'd also need to write an interface so that whoever's updating the list of disallowed words can maintain the list for both the Facebook plugin, and your own filtering.)
Quote from docs:
The comment is checked via substring matching. This means if you blacklist the
word 'at', if the comment contains the sequence 'a' 't' anywhere it will be
marked with limited visibility; e.g. if the comment contained the words 'bat',
'hat', 'attend', etc it would be caught.
Pretty sure there is no current way of doing this from the graph API, the only thing I can suggest is taking the blacklist and build your own filter