Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
tsfaridi #1
User title: Taha Saghir
Member since Mar 2011 · 15 posts · Location: Quetta, Pakistan
Group memberships: Members
Show profile · Link to this post
Subject: Facebook Chat...
Hello!

Can anyone please provide me the sample code for getting started with facebook chat integration (logging in), using existing browser session (SASL).


Regards,
Taha
Avatar
Alex #2
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you can find help under the following links:
http://www.ag-software.net/matrix-xmpp-sdk/matrix-develope…
http://www.facebook.com/sitetour/chat.php

the problem with Silverlight is the allowed port range 4502-4534. Facebooks XMPP server is running on Port 5222 and they don't run a Bosh component. To connect to Facebook from Silverlight you have to proxy all traffic through a port in the Silverlight port range. I am doing this at the Silverlight client example here:
http://matrix.ag-software.de/
which is able to conect to Facebook.

Alex
Avatar
tsfaridi #3
User title: Taha Saghir
Member since Mar 2011 · 15 posts · Location: Quetta, Pakistan
Group memberships: Members
Show profile · Link to this post
Thanks Alex!

One thing which I am unable to understand; is OnBeforeSasl event generated on call to xmppClient.Open or there is some other way? As the tutorial guides to change the SASL mechanism in this event's handler. I need sample code being used before it!


Regards,
Taha Saghir
Avatar
tsfaridi #4
User title: Taha Saghir
Member since Mar 2011 · 15 posts · Location: Quetta, Pakistan
Group memberships: Members
Show profile · Link to this post
In reply to post #2
I am using following code segment...


XmppClient xmppClient = new XmppClient();


xmppClient.OnBeforeSasl += xmppClient_OnBeforeSasl;
xmppClient.OnError += xmppClient_OnError;

xmppClient.Show = Matrix.Xmpp.Show.chat;
xmppClient.SetXmppDomain("chat.facebook.com");
xmppClient.Port = 5222;
xmppClient.ProxyType = Matrix.Net.Proxy.ProxyType.HttpTunnel;           
xmppClient.ProxyHostname = "localhost";
xmppClient.ProxyPort = 4503;

xmppClient.Open();


private void xmppClient_OnError(object sender, Matrix.ExceptionEventArgs e)
{
    gui.Dispatcher.BeginInvoke(() => MessageBox.Show(e.Exception.Message));
}

private void xmppClient_OnBeforeSasl(object sender, Matrix.Xmpp.Sasl.SaslEventArgs e)
{
    e.Auto = false;
    e.SaslMechanism = Matrix.Xmpp.Sasl.SaslMechanism.X_FACEBOOK_PLATFORM;

    e.SaslProperties = new Matrix.Xmpp.Sasl.Processor.Facebook.FacebookProperties
     {
         ApiKey = applicationKey,
         ApiSecret = applicationSecret,
         SessionKey = browserSession.SessionKey
    };
}


I got following error...
an attempt was made to access socket in a way forbidden by its access permission



Regards,
Taha
Avatar
Alex #5
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #3
Quote by tsfaridi:
One thing which I am unable to understand; is OnBeforeSasl event generated on call to xmppClient.Open or there is some other way? As the tutorial guides to change the SASL mechanism in this event's handler. I need sample code being used before it!

Not sure id I understand your question correct. You need the OnBeforeSasl event only when you want to login X-FACEBOOK-PLATFORM. You don't need it then you want to login with user and password.

Alex
Avatar
Alex #6
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
In reply to post #4
Quote by tsfaridi:
I got following error...
an attempt was made to access socket in a way forbidden by its access permission

this is a policy problem. Please read the following in the MSDN about Network Security Access Restrictions in Silverlight
http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx

I guess you have no policy socket server running, or do not host a policy file over HTTP on your remote host.

Alex
Avatar
tsfaridi #7
User title: Taha Saghir
Member since Mar 2011 · 15 posts · Location: Quetta, Pakistan
Group memberships: Members
Show profile · Link to this post
In reply to post #1
I had mentioned in my first post...
Quote by tsfaridi:
...using existing browser session (SASL).

Actually I have already integrated facebook, using facebook developer toolkit. Now the next step is to integrate facebook chat, for which I am using Matrix XMPP. Therefore, I do not need username/password authentication, I just want to use the existing browser session for X-FACEBOOK-PLATFORM SASL authentication.

Do consider my last post, containing code snippet for further clarification.


Regards,
Taha!
Avatar
Alex #8
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
what you are looking for is described here:
http://www.ag-software.net/matrix-xmpp-sdk/matrix-develope…

You also need the latest binary 1.4.0.1 because of a problem in 1.4.0.0 described here:
http://forum.ag-software.de/thread/1084-Fail-to-login-to-f…

Alex
Avatar
tsfaridi #9
User title: Taha Saghir
Member since Mar 2011 · 15 posts · Location: Quetta, Pakistan
Group memberships: Members
Show profile · Link to this post
Thanks for your assistance, it seems that there is some progress!

I have tried same code with the policy server running and got following error:
No connection could be made because the target machine actively refused it


Regards,
Taha!
Avatar
tsfaridi #10
User title: Taha Saghir
Member since Mar 2011 · 15 posts · Location: Quetta, Pakistan
Group memberships: Members
Show profile · Link to this post
In reply to post #8
Alex, waiting for your reply!
Avatar
Alex #11
Member since Feb 2003 · 4297 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
your xmpp server or proxy does not accept the connection request. This error message is coming from the Silverlight sockets classes.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS