I'm a little confused trying to adapt to the new facebook Graph API.
Whereas before I would have used events.get, I'm not entirely sure what to use now!
I can't seem to get a list of a group's events through fql, nor through the Graph API itself.
Any pointers? Should I keep using REST?
In the documentation under "Connections" it doesn't appear that you can get /events. Or for that matter /albums or anything useful...
http://developers.facebook.com/docs/reference/api/group
However, if you know that something is an event (which you could probably do because the link in the data has "eid" in it - I can't see a way beyond that) then you can call the event URL (http://developers.facebook.com/docs/reference/api/event) and get the details that way.
Related
I am using Facebook4j to access the Facebook API for a Page.
I can get a list of new posts for a Page, using
connection.getFeed()
and get the comments for a Post using:
post.getComments()
But I also want to be able to get new comments to the page posts (while ignoring comments that I've already fetched).
Any idea of how to do this, other than searching through the comments of every post all over again?
There is no way of doing it with the current Facebook4j API.
If you look at the list of the unsupported features on their page you will see:
Application APIs -Application - Facebook Developers
Ads APIs - Ads on the Graph API - Facebook Developers
Real-time Updates -Realtime Updates - Facebook Developers
Field Expansion - Field Expansion - Facebook Developers
Open Graph API - Open Graph - Facebook Developers
What you are looking for is real-time updates for the new comments.
You can take a look at this guide about subscribing to real-time updates.
If you'll look at the real-time updates link i provided above you will notice that real-time updates are limited to certain types of objects and a subset of their fields which are also listed there.
The valid types of objects for subscriptions available are the user and page Graph API object (with the feed field amongst others).
The real-time updates only indicate that a particular field has changed, they do not include the value of those fields. So this only makes apps more efficient, as they know exactly when a change has happened, and don't need to rely on continuous or even periodic Graph API requests when changes aren't happening.
You will know which field of the object (either user/page/permissions/payments) has changed, in your case the feed.
But other than that you will have to go through all the posts that you are interested in and the comments - though you could probably do it efficiently. For this you can probably keep your Facebook4j API code which gets the feed and recall it on upon updates. Or better yet upgrade the code to only track the changes you want and so on.
There is this example here (SO) on how to get facebook real time update in java. You'll get the point and probably build something better.
This answer suggests using Spring Social Facebook as it has a real-time update controller for handling real-time update callbacks from Facebook , whereas RestFB and Facebook4j can't do that.
To answer the question, if Facebook4j supports this, no, it does not.
This isn't done easily with the official graph API either, as comments use cursor based pagination; so filters like since and until will not work (they will work on things like feed though. (Source)
In order to do what you want, you would need to get all comments from now until the time you last got them. You can have comments returned ordered (most recent first, to oldest last) by using ?filter=stream
You can execute a raw fb request via fb4j for this:
// GET
Map<String, String> params = new HashMap<String, String>();
params.put("filter", "stream"); //add the ?filter=stream
//res will be the RAW response
RawAPIResponse res = facebook.callGetAPI("POST_ID/comments");
//you can get it as a JSONObj with:
JSONObject jsonObject = actual.asJSONObject();
OR, to do it without a raw request, you can use comment.getCreatedTime() to get the time for each comment, and then filter the old ones out.
Either way, you'll have to filter them yourself, as neither facebook4j nor the graph API support this natively.
How can I query facebook's graph API to retrieve all user's likes (not only pages but also photos and others)?
For instance, how could I get all the pictures a user has liked? Using facebook's search bar you can find them easily by clicking on "photos has liked".
I wrote a script that scrapes the page content and does that but it's not very efficient.
I have recently come accross a similar problem, maybe this helps you solve it.
https://graph.facebook.com/v2.5/{page_id}/feed?fields=likes.limit(1).summary(true)&since={start_date}&until={end_date}&access_token={access_token}
This will give you a list of all posts that received likes during the specified time period. If you manage to write a code summing up the following JSON path you got your sum for "all user's likes":
data[0].likes.summary.total_count
Not entirely sure is this is exactly what you were searching for, hope it helps you though - and if not you, someone else.
As for likes you can also use the same way to extract Shares and Comments:
Shares
https://graph.facebook.com/v2.5/{page_id}/feed?fields=shares&since={start_date}&until={end_date}&access_token=
Comments
https://graph.facebook.com/v2.5/{page_id}/feed?fields=comments.limit(1).summary(true)&since={start_date}&until={end_date}&access_token=
Best regards
There isn't to my knowledge any way to get this from the API without grabbing every type of response from the API and then sorting through for likes. Facebook search bar uses an internal API different from the Graph API.
I was successfully able to get the RSS feed of a page in FB using this URL.
https://facebook.com/feeds/page.php?id=PAGE_ID_HERE&format=rss20
It returns values in RSS format. Then using regular NSXMLParser methods or some so parsing protocols, I was able to parse them.But unfortunately it returns all the details of the page, such as Events, notes and etc.
I would like to get the events only. It is stated here, we can achieve it using Graph API once we obtain the general access token. My question is, can't we simply get the RSS feed for events in facebook page like the URL above? Please advise. Thank you.
It looks like the FB API and all RESTful methods of accessing data from Facebook are being retired in favour of the Graph API and FQL, whichever you prefer.
The Graph API way is to parse the JSON returned by:
https://graph.facebook.com/PAGE_ID/events?access_token=TOKEN_HERE
After skim-reading the FQL docs, I can't find a way to do it using that. So, it looks like your best hope lies with the Graph API.
I would really like to know how to do this. We have a facebook page and have a livestream from this page on our website. Now we would like to have a list of events from the facebook page in the website as well. Is it posible at all?
I'm experimenting with the Graph API, specifically the News Feed query (me/home). And right off the bat, I can see that the JSON returned does not match what I see on my own facebook page. The API returns some objects that are not on the page, and vice versa. I can't figure out what's going on here. I don't think it's about people I've unsubscribed from or anything like that.
Is this expected behavior, or am I doing something wrong? Is there documentation somewhere that explains what the difference is?
edit 22-Nov-11: this is never going to be answered, is it.
NewsFeed via api ordered by time but on facebook.com ordered by top stories
Open your recent news feed > https://www.facebook.com/?sk=h_chr
you will find that it's the same as api (y)
It is my understanding that the Post object is now Location-aware.
However, I can't seem to find documentation on how to publish location-aware Posts via the Graph API.
My app is currently publishing Checkins that reference a Place - but I would like to migrate to location-aware Posts since Places are being deprecated.
I understand that Checkins are sticking around, and that they will now reference a Page instead of a Place, but, unless I'm mistaken, the Page ID reference is still mandatory, and I am in need of my location-aware post/checkin having an optional Page reference.. hence my desire to move to Posts that have location capabilities.
Please let me know if I am incorrect in any of my assumptions..
I tried finding these questions, but none of them seem to hit exactly on the things I needed to know.
Thanks so much!
So you can now add location to posts and photos:
http://developers.facebook.com/blog/post/2012/03/07/building-better-stories-with-location-and-friends/
However I think this location is still added by giving a place ID or page ID (I'm not sure which, actually.) But I think you're asking if you can add location without a place/page ID? Personally I would like to do this as well, e.g. use lat/lon coords.
When you post through facebook proper, it can automatically add your general location (e.g. "near [nearest city/municipality]") however I don't see a way to achieve the same thing through the FB API.
You can't currently attach a location to a post via the graph api. Keep an eye on the Facebook developer blog to see if that changes.