How to connect to Facebook's XMPP (Jabber chat) server using Railo & Smack ($1,000 reward)

1,718 views
Skip to first unread message

Philip Kaplan

unread,
May 23, 2013, 6:43:50 AM5/23/13
to ra...@googlegroups.com
Hi,

This is a tough one. I've tried everything and still, facebook is telling me "not-authorized" (as you'll see).

There might be a problem with the SASLXFacebookPlatformMechanism class. I compiled it myself, despite knowing nothing about Java. Found that class (and lots of discussion around it) on the net. 

My Railo script seems to be connecting to Facebook's XMPP server successfully. But when I try to login(), it says "not-authorized". 

If you can get it to authorized (I guess use your own facebook token), I will immediately give $1,000 to the first person (or his/her charity) with the answer. Not sure if that helps get this answered faster, but the fact that I'm so desperate hopefully will. :-) 

Google the heck out of these java class names and the error message and such. Lots of conversation, with lots of people (in other programming languages) getting it working.

Again, I changed the access_key and apiToken in the example below, for security reasons. So use your own.

Thanks,
Philip

Running (lots of CFDUMPS, see the error on the bottom):

Source (please ignore how messy it is... just a lot of notes I've written while pulling my hair out)


<cfinclude template="/functions.cfm">

<cfset application.smack = "C:\www\fandalism\extras\smack4.jar"> <!--- path to smack --->
<cfset application.smack2 = "C:\www\fandalism\extras\SASLXFacebookPlatformMechanism.class"> <!--- path to smack --->

<!---
<cfset foo = createObject("java", "org.jivesoftware.smack.sasl.SASLXFacebookPlatformMechanism", application.smack2)>
<cfdump var="#foo#">
--->

<cfset SASLAuthentication = createObject("java", "org.jivesoftware.smack.SASLAuthentication", application.smack)>
<cfset XMPPConnection = createObject("java", "org.jivesoftware.smack.XMPPConnection", application.smack).init("chat.facebook.com")>
<cfset SASLMechanism = createObject("java", "org.jivesoftware.smack.sasl.SASLMechanism", application.smack)>
<cfset SASLXFacebookPlatformMechanism = createObject("java", "org.jivesoftware.smack.sasl.SASLXFacebookPlatformMechanism", application.smack2)>
<cfset UtilBase64 = createObject("java", "org.jivesoftware.smack.util.Base64", application.smack)>
<cfset XMPPConnection.DEBUG_ENABLED = true>
<cfset SASLAuthentication>
<cfdump var=#SASLAuthentication# label="SASLAuthentication">
<cfdump var=#SASLAuthentication.registerSASLMechanism("X-FACEBOOK-PLATFORM", SASLXFacebookPlatformMechanism.getClass())# label="registerSASLMechanism">
<cfdump var=#SASLAuthentication.supportSASLMechanism("X-FACEBOOK-PLATFORM", 0)#>
<cfdump var=#SASLAuthentication.getRegisterSASLMechanisms()# label="getRegisterSASLMechanisms()">
<cfdump var="#XMPPConnection.connect()#" label="connect()">
<cfdump var="#XMPPConnection.isConnected()#" label="isConnected">
<cfdump var="#XMPPConnection.isAuthenticated()#" label="isAuthenticated">
<cfset access_token = "CAACZChsyXig0BAOo"> 
<cfset apikey = '21054379006221'>

<!---
(apiKey + "|" + sessionKey, sessionSecret, "Application");
--->
<!---
--->

<cfset host = "chat.facebook.com">

<cfoutput>
<br>
apikey: #apiKey#<br>
access_token: #access_token#<br>
</cfoutput>

<cfdump var="#XMPPConnection#" label="XMPPConnection">
<cfdump var=#XMPPConnection.login(apikey,access_token)#>

Marc Lichtenfeld

unread,
May 24, 2013, 2:15:27 PM5/24/13
to ra...@googlegroups.com
Hey Philip,

Have any luck with this one yet?

Been playing with the Facebook APIs recently and I'm curious.

Going to check it out now.

Best,
Marc

Denny

unread,
May 24, 2013, 2:41:41 PM5/24/13
to ra...@googlegroups.com
I already had an openfire server extension so I figured I'd take a stab
at this too. :)

A lot is going to depend on how/why one wants to do the chatting.

If you're going to do it from the web with ajax or some such, you'll
want to use the "platform" authentication method (same as most the FB
APIs, using OAuth callbacks to get a session token).

If you're wanting to use a gateway, or some other automated type deal,
you'll want to use the "plain" MD5 digest user/password approach.

I'm working on the FB "platform" approach, as that's the harder one. It
requires adding "xmpp_login" to the permissions as well as leveraging
the OAuth callback stuff.

https://developers.facebook.com/docs/chat/

:Denny
--
Railo Technologies: getrailo.com Professional Open Source
Skype: valliantster (505)510.1336 de...@getrailo.com
GnuPG-FP: DDEB 16E1 EF43 DCFD 0AEE 5CD0 964B B7B0 1C22 CB62

Philip Kaplan

unread,
May 24, 2013, 6:39:51 PM5/24/13
to ra...@googlegroups.com
Denny,

You're exactly right.  I want to use the "platform" method, as you put it. I am getting "xmpp_login" permission from my users.

> A lot is going to depend on how/why one wants to do the chatting.

I want to programmatically send a message from one of my users (who's given me permission via Facebook oauth & "xmpp_login") to his Facebook friend. I don't need to receive messages. Just need to send a message.

Marc, Denny- No luck yet. If you figure this out I will be SO HAPPY.

Philip




--
Did you find this reply useful?  Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki


If you don't have time, add a request to the Railo Server wiki to-do page at https://github.com/getrailo/railo/wiki/Todo
---
You received this message because you are subscribed to a topic in the Google Groups "Railo" group.
For more options, visit https://groups.google.com/groups/opt_out.



Philip Kaplan

unread,
May 26, 2013, 1:05:55 AM5/26/13
to ra...@googlegroups.com
Just letting everyone know (in case anyone else was working on it) that Denny Valliant is my hero and savior. He figured it out.

Thanks!!

Philip

MrBuzzy

unread,
May 26, 2013, 2:58:19 AM5/26/13
to ra...@googlegroups.com
Actually Philip, that's a real bummer because you know I was working on it. We had chatted for a while about this offline.

Further more I sent you a few emails confirming I had 'got it to authorize' 14 hours ago. Then not another email from you, surprise!

Here is the solution I came up with using the smack library you were using. I guess I'll offer it up incase it's useful to someone else in the future;

Called it "FBChatter" just a weekend hack-job.

As for "If you can get it to authorized (I guess use your own facebook token), I will immediately give $1,000 to the first person (or his/her charity) with the answer." did you get your money Deny!?! Reads like a contract to me.

What does the community think about such carrots (and sticks)? Should messages of this type be posted to a separate job group?
 


--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
 
 
If you don't have time, add a request to the Railo Server wiki to-do page at https://github.com/getrailo/railo/wiki/Todo
---
You received this message because you are subscribed to the Google Groups "Railo" group.

Philip Kaplan

unread,
May 26, 2013, 3:13:54 AM5/26/13
to ra...@googlegroups.com
Wait, I'm confused. I thought you were the same person. I'm re-reading my emails. Totally confused now.


You received this message because you are subscribed to a topic in the Google Groups "Railo" group.

MrBuzzy

unread,
May 26, 2013, 3:22:56 AM5/26/13
to ra...@googlegroups.com
No I'm not Denny. He's certainly a gun and I wouldn't be at all surprised if he had solved it first. 

It was a good weekend exercise anyhow. But I probably should have mowed the lawns instead, doh! 

--
Did you find this reply useful? Help the Railo community and add it to the Railo Server wiki at https://github.com/getrailo/railo/wiki
 
 
If you don't have time, add a request to the Railo Server wiki to-do page at https://github.com/getrailo/railo/wiki/Todo
---
You received this message because you are subscribed to a topic in the Google Groups "Railo" group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Philip Kaplan

unread,
May 26, 2013, 3:23:54 AM5/26/13
to ra...@googlegroups.com
Holy sh-it, I am such an idiot.  Both of you are in the same Gmail thread on my end. So I thought I was having a conversation with 1 person but it was actually 2. Confusing since it was 1 thread but several 1:1 conversations & I read email really fast. 

Ugh. You'd think I'd know how email works by now. Fuuuuuuck. I feel awful. 

MrBuzzy- I'm emailing you off-list. I'll make this right.  

Sorry for blasting the whole list everyone. 

Philip

MrBuzzy

unread,
May 26, 2013, 3:28:32 AM5/26/13
to ra...@googlegroups.com
Hey don't feel aweful, mixups happen, I'm the king of that. 

And if Denny did solve it, so be it!

Paul Kukiel

unread,
May 26, 2013, 3:54:19 AM5/26/13
to ra...@googlegroups.com, ra...@googlegroups.com
I say keep the carrot on this list.  We're all here and know most of the active posters.  Can't wait to see what puds doing this time with railo!

Paul

Denny

unread,
May 26, 2013, 4:28:18 AM5/26/13
to ra...@googlegroups.com
If I fixed it? *IF*?!? ;)

I crushed that problem, saw it driven before me, and to heard the
lamentations of 5K friends! =)

Sorry about the confusion though. FWIW, here's the current result:

https://github.com/cfmlprojects/cfxmppclient

It will be (maybe already is-- needs more tests) an XMPP gateway as
well, so it will work with at least FB and Openfire (did I mention the
openfire extension?). Naturally this can be installed as an extension
too-- because as I said, I don't just solve, I crush, yo! =)

Has buddy list stuff, some status/chat listeners for hooking your
chat/status/file handlers, etc.... yep, it's getting there.

I also stumbled across this:

http://code.google.com/p/transloader/

Which didn't quite work as I wanted it to, but might still be
interesting to Micha.

For those poor souls who may find this thread, the java bit was solved
by adding this 4-argument authenticate method:

https://github.com/cfmlprojects/cfxmppclient/blob/master/src/cfxmppclient/java/src/cfxmppclient/SASLXFacebookPlatformMechanism.java#L60

Philip was a man of his word-- and he didn't have to be, as I gave him
the code first-- and now I don't have to wait to fix my cooler, so I can
crush problems like I'm cool, vs. on fire. Yippee!

Purely coincidentally, this cowboy is all for them bounties. ;)

:Denny

On 5/26/13 1:28 AM, MrBuzzy wrote:
> Hey don't feel aweful, mixups happen, I'm the king of that.
>
> And if Denny did solve it, so be it!
>

tbankert

unread,
Apr 24, 2014, 12:54:01 PM4/24/14
to ra...@googlegroups.com
Can anyone explain to me how to install this extension. and some usage examples?
Reply all
Reply to author
Forward
0 new messages