7

I would like to implement FB-chat inside a webpage. I looked around in Facebook API, i found out that chat is allowed only using XMPP. First I tried to connect to FB-chat using Pidgin and it worked fine. My conclusion was that FB-chat server is acting as the XMPP server. Is this true?

I read about XMPP, it seems that an open TCP connection should be established between the client and the server to exchange the XML stanzas which is not possible from a website (over JavaScript and without plugins) since only http requests/responses can be exchanges, no TCP connection there. This means that there should be some kind of a proxy in between, and as for authentication, FB API suggests to use the X-FACEBOOK-PLATFORM SASL (not the DIGEST MD5, since there is a proxy). I didn't find a clear tutorial or steps how to do so, help here is appreciated.

A bit more research about XMPP client from the web or browser, I saw that I am supposed to use a library called Strophe (based on BOSH protocol) and in other answers some kind of connection manager called Punjab. I read about this BOSH protocol, it seems to be the solution but in some places I found out that it is not allowed in FB (I am not sure how correct is this info though). I tried to setup these but i was totally confused how to begin and what I am really supposed to do.

For the strophe, I didn't find a real tutorial how to implement it, and in what i found, they suggest to first setup a jabber server like ejabberd (I didnt get the need for that).

My question is:

Can somebody suggest an architecture that I should implement to achieve my goal?

So will there be: webpage ->(HTTP) -> Strophe -> (TCP) -> FB-chat OR will it have an XMPP server in between and why?

I would appreciate any answer to any of my questions. Please suggest some links to how to implement all these stuff. I am totally new to all this which made me lost for more than a week now.

If somebody already did this, please help. Thanks a lot.

Sabah

4

3 回答 3

3

关于 facebook 聊天服务器的信息:

Protocol: XMPP or Jabber
Username: mathvdh
Domain: chat.facebook.com
Jabber ID: mathvdh@chat.facebook.com
Password: <your Facebook password>
Port: 5222
Server: chat.facebook.com
Use SSL/TLS: no
Allow plaintext authentication: no

我认为 strophe 和 punjab 应该是 fb 聊天的有效组合,请参见此处:用于 facebook 聊天的 XMPP 库

而且我认为架构会更像:

客户端网页/js/strophe <-> yourserver/punjab <-> facebook xmpp 聊天服务器

于 2011-05-05T13:31:58.907 回答
1

我也在努力解决这个问题。到目前为止,我已决定设置:

Jappix mini(使用 JSJAC.js 库)<-> 我的服务器上 node.js 上的 node-xmpp-bosh <-> Facebook 服务器。

Jappix mini 很难找到,但它似乎是迄今为止最好的开源聊天栏,所以在这里值得一提。

我还没有全部设置好,但如果我取得进展会在这里更新。主要问题是如何让 JSJAC 使用 Facebook API Key 身份验证。我找不到任何信息或示例,但我找到了 strophe 库的这个插件,它可能可以修改:

https://github.com/rubenjgarciab/turedsocial/blob/master/strophe-plugins/src/facebook.js

最后,您不能在 javascript 中包含您的 facebook 密钥(因为它是一个秘密!)所以您需要使用 Facebook REST API auth.promoteSession 服务器端来生成一个会话密钥,该密钥可以在 javascript 中用于签署 X -FACEBOOK-PLATFORM 身份验证请求。

希望对您有所帮助,如果/当我开始工作时,我会添加更多。

于 2011-05-19T00:05:08.280 回答
0

沙巴,

正如前面的答案中提到的,旁遮普 <-> strophe.js 有效。我在这里分叉了 facebook strophe 客户端:https ://github.com/javierfi​​gueroa/turedsocial并添加了一个示例。

希望这可以帮助。

于 2012-01-23T21:25:54.347 回答