Dmitry Khryukin
Dmitry Khryukin

Reputation: 6438

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.

Upvotes: 8

Views: 3231

Answers (2)

Mr Shadi
Mr Shadi

Reputation: 36

Facebook does not allow the SDK to send private messages to prevent misuse by spammers

Upvotes: 0

Alex
Alex

Reputation: 4136

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"};    
}

Upvotes: 3

Related Questions