How do I speed up /me/home requests? - facebook-graph-api

I have an application where I want to show items that your friends have shared. This is basically a subset of data that would appear on your Facebook News Feed, so I am grabbing /me/home and then filtering out some things that I don't need.
The problem is that /me/home is extremely slow. I'm seeing a range of response times that is between 1200 and 10000 milliseconds with an average probably around 4 seconds.
Even with cached connections and a HTTP library that does SSL correctly these request times do not change much.
Does anyone know a better way to grab the News Feed? When I open Facebook in my browser, the News Feed appears pretty much immediately. So I am wondering if there is some Graph API call that is optimized for this data or has this result cached already.
Is there maybe an FQL alternative for this?

You can do this in FQL. This query should get you started:
SELECT post_id, actor_id, target_id, message, attachment FROM stream WHERE filter_key = 'others'
In the Graph API explorer on my feed, I get ~1000ms response times for the FQL query vs. ~2500ms for me/home.
For Facebook's home page, keep in mind that they use a series of AJAX queries to fill each of the boxes on your page a little at a time. I was on a very slow connection in a hotel last week and watched these fill box by box. The news feed fills first, five posts at a time, followed by the other boxes on the page. If page load performance could be an issue, you may want to move to an asynchronous model.
FQL will definitely help with that, as you'll be able to filter the data before it is returned by FB more finely than you can with just the Graph API.

Related

Convert FQL statement to Graph

With FQL being phased out I need to achieve the same functions via the Graph API.
My application checks for new posts, comments and replies on a company page every X seconds.
I use 1 FQL to get new comments and replies by doing
SELECT post_id,time,fromid, text,id from comment WHERE time > (lastcheck) and post_id in (select post_id from stream where source_id = (PageID) limit 1000) order by time desc
This appears to work well ,I can add a comment to a 5 month old post and it picks it up.
How can the same be achieved with the Graph API?
I think that if what you have works then you do not need to change it. Contrary to what Facebook wants you to do (use the graph api), not every query can be translated to it. FQL is alive and kicking and used heavily both in the Facebook website and mobile apps.

How to access my user activity on other users' pages or fan pages using the Graph API?

I would like to find any of my own activity (post, comment, share, etc.) on another user's page or a fan page. That is, obtain a list of all the comments, posts and whatnot that I have made on user XYZ's page, or on SOMETVSHOW's page.
Is that possible at all? I've looked at the different relations that are accessible using the Graph API, but there seems to be no direct way to get this data.
One way to do this is to collect ALL of my own activity and then run this data through a filter that would extract just the comments, post, etc. that I left on a certain user's page or fan page. But that is not really efficient, especially if you have (like me) a very large amount of data to capture in the first place.
Also, I could go the other way and grab ALL of that user's or fan page's activity and the filter out my own posts and comments, but likewise, this would take an eternity and produce huge amounts of data that need to be processed.
Any ideas? Thank you!
You should be able to do this pretty easily via FQL:
SELECT post_id, type, message, created_time, attachment FROM stream
WHERE source_id = PAGE_ID AND actor_id = me() LIMIT 200
You will have the normal limitations of the stream table to deal with, so you may have to page back through these results to get everything you are looking for.

Get posts from all my Facebook Pages?

I want to get the most recent updates from my liked Facebook pages (graph.facebook.com/me/likes/). I thought I'd got it working using FQL with the below statement
SELECT source_id, share_count,likes, FROM stream WHERE source_id in (select target_id from connection where source_id=me() and target_type='page') LIMIT 100
However it seems that FB is filtering out a bunch of pages due to their various algorithms. Is there any straight forward way of getting around this? I'd just like to see all messages and decide whats relevant myself.
I was previously jumping onto every single page of my likes via the graph api, but obviously this gets a bit crazy if there are 700 odd likes in my profile.

Calling next results from WebService

I develop WP7 app and I'm calling last 20 results from webservice and I wonder how to call next 20 when user goes to the end of listbox?
I have found some topics how to recognize when user reaches end of the list but I'm struggling how to re-call WebService and ask for next entries.
EDIT:
So okay, here is the thing. In my API I have two options:
- take some amount of results (like 10, 20, 30) and then show them all on the list
- second options is to ask API to give me like 3 pages of 20 records on each page
Thinking about second option: okay I can display just 1/3 pages and then when user goes down call another page (already stored on phone) but that makes no sense as user will download all records (even he don't want to see more than top 5...
The only idea is to call next results, but don't know how to re-call webservice on some point
Your problem seems more of a web-services related than a windows phone related. Because if you are getting some data from a web service then the web service provider should ideally provide you with some documentation on how to fetch next/previous records or entries.
Here are two links from Twitter API which gives you some idea on fetching the data in pages.
Getting the home_timeline data
Working with Timelines
Here is another link which gives idea on how to implement paging in a Silverlight Application (I am not sure how far this method is compatible with WP app)
If this data couldn't answer your question, then update your question with some additional data like which url you are using to fetch the first 20 records etc

How to get user count by status of facebook events (attending, Invited, etc..)

Is there any way to get the user count by status of facebook events? Facebook does this on the event page (the left columng with each status has a count next to it), but could not find any documentation on how to do the same. It needs to work for small or large events. For small events, I can easily get the list of users and do a quick count. But for events with over 1000 users, the previous method is too slow and not acceptable.
I don't think there's a better way than count every list of users as explained below.
You can which users are 'attending' an event by issuing an HTTP GET to /EVENT_ID/attending
You can which users have replied 'maybe' to an event by issuing an HTTP GET to /EVENT_ID/maybe
You can which users are declined an event (i.e. responded 'no') by issuing an HTTP GET to /EVENT_ID/declined
You can which users have not replied to an event by issuing an HTTP GET to /EVENT_ID/noreply
Taken from https://developers.facebook.com/docs/reference/api/event/
UPDATE 28-Jun:
As of today, Facebook added new fields to the Event FQL table that allows you to do exactly what you want.
From the developers blog:
We've added the following fields to the event FQL table to make it
easier to get the counts of users RSVP-ed to an event:
all_members_count
attending_count
unsure_count
declined_count
not_replied_count
They're pretty much self-explanatory.