Notification on status updates

Sep 18, 2009 at 3:23 PM

I would like to write a Facebook application, looking at the running users status updates. Is there some part of the API, which makes it possible to get notified, each time the installing user, updates his/her status? I've looked at the open stream api, but doesn't seem to be fully supported by FDT. I'm also interested in some sort of notification api, where my web application gets notified each time a users updates his/her status. Is this even possible without having to poll the status?

Regards,

Thomas

Sep 18, 2009 at 4:15 PM

I believe the stream api works exactly like it does on facebook (at least the 3.0 branch which supports most of the beta apis). What isn't supported that you are trying to do? I can look at updating it if there is something in the steam api that FB allows, but the toolkit does not.

I don't think you are going to be able to get status updates unless you poll. Well there is one other way you could possibly do it. Login to facebook and click on notifications, then see that link to subscribe to your notifications, click that. You should get a long url like http://www.facebook.com/feeds/notifications.php?id=xxxx&viewer=yyyy&key=zzzzzz&format=rss20  Change that to be http://www.facebook.com/feeds/status.php?id=xxxx&viewer=yyyy&key=zzzzzz&format=rss20 That is RSS feed of your status. With an RSS feed you could use some pubsubhubbub server like superfeedr which would poll that feed and give you a callback when it's changed.  I don't know if you can get that link for other people though.   

Maybe there are other options, but I don't think facebook supports any push notification of status changes to app developers.

Sep 18, 2009 at 4:58 PM

Hi. Thank you for your quick reply. I don't think there is a notification API on facebook, so you are propably right.

I've looked at the FDT code, and are only able to find the latest status on the user class. What I wan't is the last 20 status updates (20 just an example).

I've already tried the rss solution. The first feed works great, but Facebook closed the status feed for some reason. When i request that url, I just get the message "This feed URL is no longer valid. Visit this page to find the new URL". They propably wan't us to visit Facebook all the timer, rather than just following in the rss reader.

Maybe I should try explaining what I want to do, and maybe someone have another solution. I'm a developer of the danish non-commercial website www.myrating.dk containing reviews and ratings of a lot of different stuff (movies, beers, restaurants etc.). I think it would be cool to let my users authorize my website with their facebook account and letting them update content on my site from facebook. Example: I've created the movie The Big Lebowski at my site. The user likes this movie and rather than creating a review/rating at my site, the user updates his/her status with the message "Just saw The Big Lebowski and thinks it's pretty cool. I'll give it 9/10 stars". When writing this message, my code is notified (maybe by polling) and figures out that a user says something about The Big Lebowski. Then I'm able to parse the message and look for item name and the rating (9/10). When successfully parsed, my code could automatically create a review and a rating at my site with the text and stars of the facebook message.

Sep 18, 2009 at 5:35 PM

Weird, the status feed works for mine. I still don't think you can get that for other people though because of the datakey. 

For now the best way to do what you want is to use the stream api or fql. I've only been using the 3.0 branch so I don't know if the same things are applicable in the 2.x branch. In 3.0 you can do somehting like

 

                var viewerId = _api.Users.GetLoggedInUser();
                var stream = _api.Stream.Get(viewerId, new List<long>() {viewerId}, lastPollDate, null, 30)

                var viewerId = _api.Users.GetLoggedInUser();

                var stream = _api.Stream.Get(viewerId, new List<long>() {viewerId}, lastPollDate, null, 30)

 

This will give you all posts to the stream. You're going to have the statuses with attachments like pics and links though which you may or may not want. 

In 3.0 we also have a method to just get the statuses - go to http://developers.facebook.com/tools.php and try status.get. We have code implemented for that, but it's not currently avaiable to all developers so you probably will get an a message about method not found. But you can make an FQL query like "select uid,status_id,message from status where uid = 111111111" That will give you back all the statuses the same way as the status.get() api method. I'm not sure what the limit is. Mine returns quite a bit.

Have you thought about doing what you want on Twitter? I mean obviously you could do both, but it's a little simpler on twitter because all it is is status messages and you could use something like http://excla.im/ to get a push notification via xmpp. What you want will probably be hard to parse in either case. I think you'd need to use the new mentions in facebook  @username (that is easy on twitter since people always do it already) or build a pulisher for your app so people can insert ratings into their feed - http://wiki.developers.facebook.com/index.php/Publisher .  If you use the publisher then you can have some input fields and it'llbe much easier for you to get the data. Good luck on the app and i'll let you know if i think of any other possible solutions.

 

Sep 18, 2009 at 5:52 PM

From your code it looks like i may be able to get the status messages from other users using either FQL query or the _api.Stream.Get method. I will check that out. Alternative I could maybe implementat a real facebook plugin, which the users install their facebook. Maybe some types of plugins are executed by facebook when user looks at his/her own profile. This could be a thing to examine if the stream api doesn't do the trick.

Regarding the Twitter integration I already have this implemented. And as you say, this is much easier in Twitter. This feature requires thu users of my site to attach their twitter username with their profile. When done, I poll the Twitter search api every 5 minuttes, searching for the string #myrating. This means that users are able to write "Just saw The Big Lebowski and give it 9/10 start at #myrating" and this is automatically found my by polling mechanism. The username is then looked op in my db and the comment attached The Big Lebowski at my site. Works pretty good, but I would like sort of the same feature on Facebook as well :)