Performance boost needed - app users fanpage likes check - facebook

I have performance issues with my facebook app.
I need to check, if app users friends like an fanpage. But problem is: time.
One query to graph /fanpage_id/members/userId needs ~200ms (my test user have 4 friends, time was 977ms). Customer want at last one check per 24hours(app cache remove event on global.asax works well) for all users BUT.. lets say 500 users and every user have 500 friends * 200ms .. its a lot of time and queries to facebook graph.
Any ideas how improve it ?

Have you tried batch requests?

You should be able to reduce the time by using the ?fields= &fields= parameter and only requesting the id's of friends and id's of like objects.
when you request friends /me/friends?fields=id
http://developers.facebook.com/tools/explorer/?method=GET&path=me%2Ffriends%3Ffields%3Did
foreach id:
when you request likes /id/likes?fields=id
http://developers.facebook.com/tools/explorer/?method=GET&path=me%2Flikes%3Ffields%3Did

Related

Fetching activity feeds of all the users together in a request

I have a facebook application which posts on users activity feed as soon as the user uses my website. I am also trying to show the activity of users' friend on my website. For this , I am fetching back the feeds being posted by my application on facebook for his friends.
However, the problem is , in the first request , I am getting the list of all the friends of the respective user who have installed my application. Once, I get this list, I am able to get his friends, however, only one at a time.
So, if a user has 50 of his friends using my website, it will take 50 request to show him his friends activity. Is there a way in facebook open graph to fetch the list of all feeds of all friends together, or, using least number of requests ?
Please suggest some ways to do the same.
If you are using FQL to grab the data, you can use WHERE uid IN (…,…,…) to select data for more than one user at once.
And with FQL you can do multi-queries, or using the API you can do batch requests; to reduce the number of HTTP requests necessary to get the data.

Changing the limit of number of activity feeds of friend fetched using graph API at a time

I am trying to have a hold of number of activity posts made by my application on Facebook.
However, Fb returns only 100 activity feeds at a time. So, if a user has lets say posted 200 times on FB. I would have to request twice. Similarly, I would need to do for all of his friends. This is very inconvenient ad inefficient. So, is there anyway to change the limit of number of feeds fetched at a time
Here is the feed sample from one of my users.
Thanks !

limit posts to wall on fb app

I have an fb app connected with my website. it will trigger a post to fb user's wall when he completes a search on my site. Is there anyway to have a limit on the number of posts to the wall? say 1 post per day or 3 posts per week?
Take a look at the Graph API documentation. Basically, Facebook will send you a Graph object for each of the users that log in. You can just keep a table in your DB that maps users to a counter for how many posts you've made to their wall, which you always check before posting to make sure it's not over the limit. When the time period is up, you can just reset the counter.
Here is some example code that will show how to access the Graph object: http://www.devshed.com/c/a/PHP/Facebook-PHP-API-Applications-Working-with-User-Data/

How do I sort my products by most liked on Facebook?

If I have an e-commerce site, for instance, where I have a selection of products that each gets a 'Like' button, how would I go about ranking these products in order of their popularity?
What I do is, I store the number of likes locally on my own Database.
You can grab the number of likes for a URL from link_stats table:
http://developers.facebook.com/docs/reference/fql/link_stat/
I looked around a lot for a simpler solution, but it's best if you store the number of likes locally. You can update your local value when a user clicks on the like button or you can do it every so often for all URLs if you don't have that many. I personally update the number of counts for all my URLs once every 24 hours.
-Roozbeh
You may be able to do it if you have all your products on one page using this tool:
http://www.pagesort.com
I suggest you keeping local reference count (in database) and set up facebook realtime update on those objects. So every time somebody likes your url (object), facebook service will post update to your api. https://developers.facebook.com/docs/reference/api/realtime/

Getting all facebook page wall posts and comments?

I am developing a social media monitoring application. Currently, we are entering Facebook page ids into the application to collect data from possible customers' Facebook walls (so we have a realistic sample for the customer for direct promotion).
These page ids are used to collect wall postings and comments and to compute statistics (e.g. to show most used words), and are presented to the user in a special view. Requirements are to collect all postings and comments without exception in near-live time. We currently have about 130 page ids in the system, with more to come.
Right now, I am using the Graph API for this, with several disadvantages:
FB API access is restricted to 600 request/10 minutes. To get a near-live view, I need to access the API at least each two hours. As we are using API requests in other parts of the program, too, it is obvious that the limit is hit sooner or later (actually, this already happens)
The responses are mostly redundant: to receive current comments, I have to request the wall postings (comments are enclosed in postings) with the URL http://graph.facebook.com/NAME/feed...
The probability for hitting the limits is dependent on the number of postings on the several walls
I cannot get all comments with this method (e.g. comments on postings some time ago)
I am currently trying out how to switch to (or to complement Graph API usage) using FQL by querying the stream and the comment tables but this also has limitations:
I cannot restrict my query to a specific timespan, leading to redundancy again
The max number of posts I am getting for each one of my 130 page ids is 61 - (why 61?)
I need an unpredictable number of additional requests because I need to get special objects like videos and links in separate requests.
My question now is - if anyone is doing similar things: How did you solve these problems? How do you get a pseudo-live-stream of a larger number (up to, say 1,000) of walls?
Letting the customer grant extra permissions to us is currently not an option.
you will probably have to meet with FaceBook and work out a contractual deal for greater access to their data. I would bet that the answer will be no, no and no, seeing as it appears you are trying to monetize their data, and furthermore, do so without the explicit permission of the users, but hey give it a shot.
I have a similar task - By default FB return only last ~50 posts or all in last 30 days(whichever is smaller) in FQL you should use created_time filter to receive more results. my current problem is that via FQL I receive no more than ~500 posts from any FB page wall even when LIMIT increased:
'select post_id from stream where source_id = 40796308305 and created_time <'.time().' LIMIT 1000000 ;'
this FQL request to CocaCola FB Page returns now ~300 posts only (less than 2 day posts).
If you find a better solution pls advise :)