Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send private messages with Facebook API using C#

I use Facebook Connect for login on my website and need to create functionality of sending personal messages to user's Facebook friends.

A solution from this question is not suitable for me because I need to send messages to several friends at the same time (user just selects friends from the list who she/he wants to send a message).

I've found pretty good post about this question for Ruby - How to send private messages with Facebook API. But I can't find a C# package similar to xmpp4r_facebook Ruby gem.

agsXMPP SDK and jabber-net don't support X-FACEBOOK-PLATFORM SASL mechanism (http://forum.ag-software.de/thread/1372-Facebook-Chat and Connect to facebook chat using Jabber.net (C#/Mono) with SASL).

I hope to find some existing solution instead of updating one of these libraries. Or to find some library like xmpp4r_facebook but for .NET platform.

Thanks.

like image 686
Dmitry Khryukin Avatar asked Sep 26 '12 05:09

Dmitry Khryukin


1 Answers

The latest sources of agsXMPP supports the X-FACEBOOK-PLATFORM Sasl mechanism.

1) checkout the latest sources
2) add the following code to the OnSaslStart event

private void XmppCon_OnSaslStart(object sender, SaslEventArgs args)
{
   args.Mechanism = Mechanism.GetMechanismName(agsXMPP.protocol.sasl.MechanismType.X_FACEBOOK_PLATFORM);
   args.ExtentedData = new FacebookExtendedData {AccessToken = "YOUR TOKEN", ApiKey = "YOUR API KEY"};    
}
like image 150
Alex Avatar answered Nov 01 '22 15:11

Alex