I think this what you need
/*
* Implements hook_services_resources
*/
function your_module_name_services_resources() {
return array(
'add_user' => array(
'create' => array(
'help' => 'Add users to group',
'callback' => 'your_module_add_user_to_group',
'access callback' => TRUE,
'access arguments append' => TRUE,
'args' => array(
array(
'name' => 'uid',
'type' => 'id',
'description' => 'The uid of the user to add in group',
'source' => array('data' => 'uid'),
'optional' => FALSE,
),
),
),
),
);
}
/*
* Call back to add the user
*/
function your_module_add_user_to_group($uid) {
$user_account = user_load($uid);
$og_values = array(
'entity_type' => 'user',
'entity' => $user_account,
'state' => OG_STATE_ACTIVE,
);
//This is will add the group to the user.
og_group('node', $your_group_nid, $og_values);
user_save($user_account);
return success;
}
Put this code in your custom module file. And go to "Structure->service->your_end_point->enable 'add_user' resources"
Then call
url : http://localhost.com/endpoint/add_user
method: POST
In data field data: uid=595 (pass the user id for whom you need to add the group);
I think this will do the trick.