在ELGG中创建/编辑组web服务


Create/edit group web-service in ELGG

我正在寻找创建组的Web服务。我查看了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服务的吗。

请在ELGG/engine/lib/web_services.php 中的Web服务文件中添加以下函数及其定义

/**
 * 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.
}

最后,您应该公开如下函数:

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
    );
PawełSroka是对的。您可以制作一个包含manifest.xml和start.php的基本插件,并将代码放在start.php中,在其中编写单个函数或数百个函数都无关紧要。例如,您可以查看以下插件:https://github.com/markharding/elgg-web-services