1

我正在寻找可以创建组的网络服务。我查看了 elgg 中可用的网络服务。我只能找到以下与该组相关的 Web 服务 -

团体

  • group.join 加入群组
  • group.leave 离开一个组
  • group.forum.save_post 向群组发布新主题
  • group.forum.delete_post 从组中删除主题
  • group.forum.get_latest_post 获取群组中的最新帖子
  • group.forum.get_reply 获取帖子的回复
  • group.forum.save_reply 发表回复
  • group.forum.delete_reply 删除回复

我们有什么可以在 elgg 中创建组 Web 服务吗?

4

2 回答 2

1

Please add following function, and its defination in your webservice file in ELGG/engine/lib/web_services.php

/**
 * The group.save API.
 * This API call lets a user to create group.
 *
 * @param string $name group name
 * @param string $briefdescription short description
 * @param string $description long description
 * @param string $interests tags comma separated
 * @param int $group_guid GUID of group if its edit request
 *
 * @return bool success/fail
 * @access public
 */
function group_save($name, $briefdescription, $description, $interests, $group_guid)
{ 
   //you can change/pass below parameters from POST
   $_GET['action']='groups/edit';
   $_POST['membership'] = '2';
   $_POST['activity_enable'] = 'yes';
   $_POST['blog_enable'] = 'yes';
   $_POST['forum_enable'] = 'yes';
   $_POST['pages_enable'] = 'yes';

   //include file at location "ELGG/mod/groups/actions/groups/edit.php"
   include_once '../../mod/groups/actions/groups/edit.php';

   //Or you can copy all code from that file and paste it here. And do modification according to your need.

}

Finally, you should expose a function like following:

expose_function(
        "group.save",
        "group_save",
        array(
                        'name' => array ('type' => 'string'),
                        'briefdescription' => array ('type' => 'string'),
                        'description' => array ('type' => 'string'),
                        'interests' => array ('type' => 'string'),
                        'group_guid' => array ('type' => 'int', 'required' => false),
        ),
        'User add/edit group',
        'POST',
        true,
        true
    );
于 2013-11-20T09:05:18.030 回答
0

Paweł Sroka 是对的。您可以制作一个包含 manifest.xml 和 start.php 的基本插件,并将代码放在 start.php 中,无论您在其中编写单个函数还是数百个函数都没有关系。例如,您可以查看以下插件:https ://github.com/markharding/elgg-web-services

于 2013-11-20T19:52:34.927 回答