Skip to content

PHP API v1

Maxence Lange edited this page Jun 27, 2017 · 10 revisions

Calling the API

use OCA\Circles\Api\v1\Circles;


Using the API to manage Circles

Circles::createCircle($type, $name);

Create a new circle and make the current user its owner.
You must specify type and name. type is one of this value:

CIRCLES_PERSONAL is 1 or 'personal';
CIRCLES_HIDDEN is 2 or 'hidden';
CIRCLES_PRIVATE is 4 or 'private';
CIRCLES_PUBLIC is 8 or 'public'; 

returns \OCA\Circles\Model\Circle

Circles::joinCircle($circleId);

This function will make the current user joining a circle identified by its Id.

returns \OCA\Circles\Model\Member

Circles::leaveCircle($circleId);

This function will make the current user leaving the circle identified by its Id. Will fail if user is the owner of the circle.

returns \OCA\Circles\Model\Member

Circles::listCircles($type, $name = '', $level = 0);

This function list all circles fitting a search regarding its name and the level and the rights from the current user. In case of Hidden circle, name needs to be complete so the circle is included in the list (or if the current user is the owner)

example: Circles::listCircles(Circle::CIRCLES_ALL, '', 8); will returns all circles when the current user is at least an Admin.

returns \OCA\Circles\Model\Circle[]

Circles::detailsCircle($circleId);

Returns details on the circle. If the current user is a member, the members list will be return as well.

returns \OCA\Circles\Model\Circle

Circles::destroyCircle($circleId);

This function will destroy the circle if the current user is the Owner.

returns nothing


Using the API to manage Members

Circles::addMember($circleId, $userId);

This function will add a user as member of the circle. Current user need at least to be Moderator.

returns \OCA\Circles\Model\Member[]

Circles::removeMember($circleId, $userId);

This function will remove a member from the circle. Current user needs to be at least Moderator and have a higher level that the targeted member.

returns \OCA\Circles\Model\Member[]

Circles::levelMember($circleId, $userId, $level);

Edit the level of a member of the circle. The current level of the target needs to be lower than the user that initiate the process (ie. the current user). The new level of the target cannot be the same than the current level of the user that initiate the process (ie. the current user).

returns \OCA\Circles\Model\Member[]


Using the API to manage Shares

Circles::shareToCircle($circleId, $source, $type, array $payload, $broadcaster);

This function will share an item (array) to the circle identified by its Id.
Source is the app that is sharing the item and type can be used by the app to identified the payload.

return nothing


Using the API to manage Links

Circles::linkCircle($circleId, $remote);

Initiate a link procedure. Current user must be at least Admin of the circle.
circleId is the local circle and remote is the target for the link.
Remote format is: <circle_name>@<remote_host> when remote_host must be a valid HTTPS address.

returns \OCA\Circles\Model\FederatedLink