facebook chat using strophe, punjab

有些话、适合烂在心里 提交于 2020-01-06 03:08:13

问题


using the answer of my previous question and another post I tried to implement facebook-chat from a browser. Here is what I did:

  1. on an ubuntu virtual machine, I have python 2.6.5, python-twisted-conch 1:10.0.0-2, python-twisted-names 10.0.0-1, python-twisted-web 10.0.0-1 and python-twisted-words 10.0.0-2 already installed. I did not install jabberd2 server, I assumed facebook server is the Jabber/XMPP server in my case. Also I did not install pyopenssl.
  2. downloaded and untared punjab from here
  3. run it using the following command
user@ubunto: sudo twistd punjab

sometimes it tells that the process is already running under PID xxx but most times the reply was

Removing stale pidfile /home/user/twistd.pid

Does this mean that punjab is running?

In the punjab.tac file, according to this post I change the root.putChild line to

root.putChild('bosh', b)

On the other hand, I have an apache server running on the host computer (windows xp) to host my webpage that uses Strophe. In the apache config file httpd.conf, I proxy the BOSH requests to punjab at port 5280 using:

<IfModule proxy_http_module>
   ProxyRequests Off 
   ProxyPass /bosh http://ubunto_ipAddress:5280/bosh
   ProxyPassReverse /bosh http://ubunto_ipAddress:5280/bosh
</IfModule>

Note that the host and the virtual machine are bridged, so both get their IP address from the router and each one can ping the other. I also didn't install a jabber/xmpp server, or

For testing, I use the basic example of strophe as my webpage basic.html and basic.js with JID: FB_username@chat.facebook.com & password: FB_password.

I get the following:

Strophe is connecting.
SENT: <body rid='1709425072' xmlns='http://jabber.org/protocol/httpbind' to='chat.facebook.com' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>
Strophe is disconnecting.

Is there anything wrong or missing? Please help since I am not finding real documentation other than some posts concerning this issue. Thanks
Sabah


回答1:


I'm not certain this is what you're trying to do, but if you're trying to have a webpage independently connect to Facebook Chat via JS, it's not going to work due to Cross Site Scripting protections. You can only use Strophe to connect to the same server that issued the webpage Strophe is working on. You'll have to connect back to your server first and use that as an inbetween; or use iframes to embed facebook chat in your webpage.

(For the record, I know nothing about Python, but it looks like your problem is with the JS :) )



来源:https://stackoverflow.com/questions/5979295/facebook-chat-using-strophe-punjab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!