惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

博客园 - canbeing

Cocos2d-x游戏引擎实战开发炸弹超人项目教程 全套下载 1至6课 关于Android多项目依赖在Eclipse中无法关联源代码的问题解决 免费将Mac OS X从Snow Leopard升级到Mountain Lion 文档在线预览:文档生成技术细节 文档在线预览:总体思路 开发服务器恢复手记与心得 养成良好习惯 铸造高效管理 计算机管理:电脑定时开关机 [深圳]金蝶软件招聘多名网站架构师、规划师、开发工程师、策划师、设计师 微博平台StatusNet研究(4):快速安装 微博平台StatusNet研究(3):友好URL与OpenID支持 微博平台StatusNet研究(2):基本安装 微博平台StatusNet研究(1):介绍 分享微博平台间的信息同步方法 在线服务器性能状态监控预警软件推荐:监控宝 VPS上安装LAMP(Linux+Apache+MySQL+PHP)步骤 [已送完]赠送Google Wave 邀请码 偶对《蜗居》人物的观点感想 Linux使用入门与服务器管理交流 PPT
微博平台StatusNet研究(5):支持Jabber/Gtalk
canbeing · 2010-01-30 · via 博客园 - canbeing

作为微博平台,支持通过IM发布、接收信息是基本功能之一,今天讲的就是如何让StatusNet支持Jabber/Gtalk。

Jabber服务器可以使用Openfire开源项目自行搭建或者使用现成的平台(如:Gtalk)。Jabber客户端,用PHP的开源项目XMPPHP实现。这里将以Gtalk及XMPPHP为例讲解StatusNet中Jabber/Gtalk的配置。

1、注册Gtalk账号

账号作为Jabber机器人,用于接收和发送消息,我注册的是用户是canbeing.com@gmail.com,假设密码为test。

2、下载XMPPHP

3、修改配置文件

在config.php里做如下设置(以我的gtalk为例):

# xmpp using gtalk example
$config['xmpp']['enabled'= true;
$config['xmpp']['server'= 'gmail.com';
$config['xmpp']['host'= 'talk.google.com';
$config['xmpp']['port'= 5222;
$config['xmpp']['user'= 'canbeing.com';
$config['xmpp']['encryption'= false;
$config['xmpp']['resource'= 'canbeingxmpphp';
$config['xmpp']['password'= 'test';
$config['xmpp']['public'][] = 'canbeing.com@gmail.com';
$config['xmpp']['debug'= true;

4、安装PHP扩展

需要安装启用PHP的openssl和mbstring扩展,因为Jabber的通信会用到TLS以及SASL。

5、修改部分代码

statusnet 0.8.2 jabber部分代码有点问题,需要做些修改:

在lib/jabber.php里找到函数jabber_connect,将原来的

if (!$conn) {
    
return false;
}
$conn->autoSubscribe();
$conn->useEncryption(common_config('xmpp', 'encryption')); 
try {
    
$conn->connect(true); // true = persistent connection
catch (XMPPHP_Exception $e) {
    common_log(LOG_ERR
, $e->getMessage());
    
return false;
}
$conn->processUntil('session_start');

改为

if (!$conn) {
    
return false;
}
try {
    
$conn->connect(true); // true = persistent connection
catch (XMPPHP_Exception $e) {
    common_log(LOG_ERR
, $e->getMessage());
    
return false;
}
$conn->processUntil('session_start');
$conn->autoSubscribe();
$conn->useEncryption(common_config('xmpp', 'encryption'));

6、支持接收消息

做完前面5步,已经可以实现Jabber账号的绑定了,但由于B/S的程序不能保持Jabber账号一直在线,故无法接收消息。

statusnet提供了一个以daemon方式运行的php脚本在scripts/xmppdaemon.php,在命令提示符里运行如下全食即可打开一个窗口一直运行对应脚本。

C:\Inetpub\php-5.2.12-nts\php -c C:\Inetpub\php-5.2.12-nts\php.ini H:\13.PHP\04.WorkSpaces\statusnet\statusnet-0.8.2\scripts\xmppdaemon.php(具体路径需要根据实际的PHP目录及StatusNet设置)

可能碰到的问题

1、验证时提示错误

:Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in H:\13.PHP\04.WorkSpaces\XMPPHP\XMPP.php 

问题原因:未安装openssl扩展

解决方案:安装openssl扩展

2、Jabber验证时提示:Auth fail

问题原因:Jabber服务器、用户名、密码设置错误或者程序自身的bug

解决方案:按照上面步骤3进行Jabber相关配置或者按照步骤5修改部分代码

3、步骤6运行脚本时提示:Call to undefined function pcntl_fork()

问题原因:PHP未以fastcgi的方式运行,未能找到函数

解决方案:配置一个以fastcgi的方式运行的PHP来单独运行这个daemon

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。