Gtalk PHP API 简单例子(基于XMPP)
时间:2011-07-26
来源:互联网
转:JessonChan
1.下载库文件
传送门:http://code.google.com/p/xmpphp/
或者使用svn co出来: svn://netflint.net/xmpphp
简单说明:
XMPPHP is the successor to Class.Jabber.PHP that I've been promising for years. Taking advantage of PHP5, I believe it to be an elegant solution with a direct approach.
Some of the features include:
Connect to any XMPP 1.0 server (Google Talk, LJ Talk, jabber.org, etc)
Supports TLS encryption
Several XML processing approaches and supported styles (process indefinitely, processUntil an event, processTime for a number of seconds), waiting on events or map them, etc.
2.使用方法
解压。其中./XMPPHP为所需文件。其它为例子
3.示例代码
复制代码
4.返回消息
其中,*是用来对个人信息替换的。
1228*****
[INFO]: Connecting to tcp://talk.google.com:5222 1228****
[INFO]: Starting TLS encryption 1228****
[INFO]: Attempting Auth... 1228****
[INFO]: Auth success! 1228****
[INFO]: Bound to [email protected]/xmpphp*** 1228****
[INFO]: Session started ok
Gtalk PHP API 简单例子(基于XMPP)
1.下载库文件
传送门:http://code.google.com/p/xmpphp/
或者使用svn co出来: svn://netflint.net/xmpphp
简单说明:
XMPPHP is the successor to Class.Jabber.PHP that I've been promising for years. Taking advantage of PHP5, I believe it to be an elegant solution with a direct approach.
Some of the features include:
Connect to any XMPP 1.0 server (Google Talk, LJ Talk, jabber.org, etc)
Supports TLS encryption
Several XML processing approaches and supported styles (process indefinitely, processUntil an event, processTime for a number of seconds), waiting on events or map them, etc.
2.使用方法
解压。其中./XMPPHP为所需文件。其它为例子
3.示例代码
- <?php
- require('XMPPHP/XMPP.php');
-
- $conn = new XMPPHP_XMPP('talk.google.com', 5222, '[email protected]',
- 'passwd', 'xmpphp', 'gmail.com', $printlog = true,
- $loglevel = XMPPHP_Log::LEVEL_INFO);
-
- try {
- $conn->connect();
- $conn->processUntil('session_start');
- $conn->presence();
- $conn->message('[email protected]', 'Hi! This is a
- test message for PHP API of Gtalk~');
- //sb is short for somebody, to whom you want to send ,
- // a joke!哈哈,就是SB
- $conn->disconnect();
- } catch(XMPPHP_Exception $e) {
- die($e->getMessage()); //异常
- }
- ?>
其中,*是用来对个人信息替换的。
1228*****
[INFO]: Connecting to tcp://talk.google.com:5222 1228****
[INFO]: Starting TLS encryption 1228****
[INFO]: Attempting Auth... 1228****
[INFO]: Auth success! 1228****
[INFO]: Bound to [email protected]/xmpphp*** 1228****
[INFO]: Session started ok
作者: 听老歌 发布时间: 2011-07-26
感谢楼主,留个记号备用。
作者: lsstarboy 发布时间: 2011-07-26
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28