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

时间:2013-11-20 09:05:18

标签: php web-services elgg

我正在寻找可以创建群组的网络服务。我查看了elgg中可用的Web服务。我只能找到以下与该组相关的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中是否有任何创建群组网络服务的内容。

2 个答案:

答案 0 :(得分:1)

请在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.

}

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

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
    );

答案 1 :(得分:0)

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