本文介绍了使用Strophe,旁遮普邦进行Facebook聊天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用我之前的问题和另一篇帖子我试图实现facebook-chat从浏览器.这是我所做的:

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. 在ubuntu虚拟机上,我有 python 2.6.5 python-twisted-conch 1:10.0.0-2 python-twisted-已经安装了名称10.0.0-1 python-twisted-web 10.0.0-1 python-twisted-words 10.0.0-2 .我没有安装了jabberd2服务器,在我的情况下,我假设facebook服务器是Jabber/XMPP服务器.我也没有安装pyopenssl.
  2. 此处
  3. 下载并解压旁遮普
  4. 使用以下命令运行它
  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

有时它表明该进程已经在PID xxx下运行,但是大多数情况下答复是

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

这是否意味着旁遮普正在运行?

在punjab.tac文件中,根据这篇文章我将root.putChild行更改为

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

root.putChild('bosh', b)

另一方面,我有一台 apache 服务器运行在宿主计算机上(windows xp),用于托管使用 Strophe 的网页.在apache配置文件 httpd.conf 中,我使用以下命令将BOSH请求代理到端口5280的旁遮普邦:

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>

请注意,主机和虚拟机是桥接的,因此它们都可以从路由器获取IP地址,并且每个ping通对方.我也没有安装jabber/xmpp服务器,或者

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

为了进行测试,我将strophe的基本示例用作我的网页 basic.html basic.js JID :[email protected]& 密码: FB_password.

For testing, I use the basic example of strophe as my webpage basic.html and basic.js with JID: [email protected] & password: FB_password.

我得到以下信息:

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

推荐答案

我不确定这是您要尝试的方法,但是如果您要让某个网页通过JS独立连接到Facebook Chat,由于跨站点脚本保护,因此无法正常工作.您只能使用Strophe连接到发布了Strophe的网页的同一服务器.您必须首先连接回服务器,并将其用作中间节点;或使用iframe将Facebook聊天嵌入到您的网页中.

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.

(根据记录,我对Python一无所知,但看来您的问题出在JS :))

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

这篇关于使用Strophe,旁遮普邦进行Facebook聊天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:20