1. 云栖社区>
  2. PHP教程>
  3. 正文

Gtalk PHP API 简单例子(基于XMPP)

作者:用户 来源:互联网 时间:2017-12-01 13:43:51

下载传送门

Gtalk PHP API 简单例子(基于XMPP) - 摘要: 本文讲的是Gtalk PHP API 简单例子(基于XMPP), 1.下载库文件 传送门:http://code.google.com/p/xmpphp/ 或者使用svn co出来: svn://netflint.net/xmpphp 简单说明: XMPPHP is the successor to C

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());  //异常    }?>

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)》 » 本文链接地址:http://www.jijiwaiwai.info/2011/07/25/gtalk_php_api_xmpp_example/ » 如果喜欢可以:点此订阅本站

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索下载 传送门 ,以便于您获取更多的相关知识。