Jul 14, 2009 at 5:02 PM

Having my first problem solved thanks to this Discussions page (which is the Facebook Chat API thread), I'm now facing another problem.

The main purpose of my application is to let facebook users interact with each other with a "chatting system", now since Facebook does not give developers the ability to acces their chat system, I'm going to give Livemessages a try

Here's a good example on how to do it, it is very simple send, and receive messages, but the livemessage class found in this toolkit does not provide with the necessary members to listen received messages.


Does anyone knows how can I listen to messages that are being sent to my application using Livemessage?



Jul 16, 2009 at 4:43 PM

Check out the docs here:

Jul 16, 2009 at 6:28 PM
Edited Jul 16, 2009 at 6:29 PM

Well this ting is kind of confusing, how do I receive messages from this livemessage.send("event_name","Message Text"); the docs don't show me how to do that.

Jul 16, 2009 at 9:26 PM

You receive by setting up the callback handler that it mentions. See the linked example page for a full example.

Jul 17, 2009 at 2:53 PM

I'm sorry man but you are telling exactly what the page tells me, that's what I don't understand how do I set up callback handle ?
The docs tells me to do it this way :

var livemessage = new LiveMessage('message', function(data) { // successfully received a message add_message_line('From ' + data.from + ': ' + data.msg); }); 

and using this toolkit I can only make this instance of Livemessage :

facebook.liveMessage Msg = new facebook.liveMessage(service.API);

How am I supposed to recieve messages ? there isn't an event for that ?

Jul 20, 2009 at 6:06 PM

You can't actually receive the message in your back-end C# code. The message gets sent directly to the user's browser, so the callback must be set up in JavaScript (or more specifically, FBJS, Facebook's version of JavaScript). I probably should have made that more clear. Keep in mind that any code on the Facebook Developers wiki is not going to be C# code - the platform itself is language agnostic, so most of the time they just use PHP for an example of back-end code, and usually anything else you see there is going to be JavaScript.

You could probably handle the received message on the back-end through some sort of AJAX calls in your JavaScript callback, but I don't know entirely how to do that off-hand.

I believe this only works for web apps, though. If you're still trying to make a desktop chat application, like you mentioned on another thread, I don't think you can do it with this API.