到http://www.igniterealtime.org/projects/openfire/plugins.jsp下载一个插件User Service。
这个插件的作用就是允许程序设计师通过http管理openfire的用户。
部署以后默认user service是没有开启的,你需要到后台开启并且设置验证码,为了确保安全你也许还要设置一个安全的ip~~
服务器部署完成
下面看看如何使用程序调用。
以注册用户为例,以下是我写的一个注册函数
PHP代码
- function regIMFunction($userid,$plainpwd,$uname,$email)
- {
- $f = fopen("http://im.blogguy.cn:9090/plugins/userService/userservice?type=add&secret=J7y&username=$userid&password=$plainpwd&name=$uname&email=$email",'r');
- $response = fread($f, 1024);
- if (ereg('OK', $response)) {
- return true;
- } else {
- return false;
- }
- fclose($f);
- }
这样可以实现同步注册。
其他:所有参数如下
The following parameters can be passed into the request:
Name | Description | |
---|---|---|
type | Required | The admin service required. Possible values are add, delete, update |
secret | Required | The secret key that allows access to the User Service. |
username | Required | The username of the user to add, update or delete. ie the part before the @ symbol. |
password | Required for add operation | The password of the new user or the user being updated. |
name | Optional | The display name of the new user or the user being updated. |
Optional | The email address of the new user or the user being updated. | |
groups | Optional | List of groups where the user is a member. Values are comma delimited. |