Skip to content

Latest commit

 

History

History
120 lines (76 loc) · 2.9 KB

File metadata and controls

120 lines (76 loc) · 2.9 KB

Groups — PHP SDK ($greenApi->groups)

Source: src/tools/Groups.php
Docs: https://green-api.com/en/docs/api/groups/

Group chatId format: ...@g.us (Chat Id). Never invent IDs — use API responses.


createGroup

Docs: https://green-api.com/en/docs/api/groups/CreateGroup/

public function createGroup(string $groupName, array $chatIds): stdClass
Param Required Docs
groupName yes Max 100 characters
chatIds yes Array of participant chatIds (phone@c.us)

Rate (docs): no more than 1 group every 5 minutes. Simulate human pacing.

Success data:

Field Description
created boolean
chatId group id @g.us
groupInviteLink invite URL

Risks: non-WhatsApp numbers in chatIds → errors / ban risk. Prefer serviceMethods->checkWhatsapp first.


updateGroupName

Docs: https://green-api.com/en/docs/api/groups/UpdateGroupName/

public function updateGroupName(string $groupId, string $groupName): stdClass

getGroupData

Docs: https://green-api.com/en/docs/api/groups/GetGroupData/

public function getGroupData(string $groupId): stdClass

Returns group metadata and participants (see docs for full schema).


addGroupParticipant / removeGroupParticipant

Docs: Add, Remove

public function addGroupParticipant(string $groupId, string $participantChatId): stdClass
public function removeGroupParticipant(string $groupId, string $participantChatId): stdClass

setGroupAdmin / removeAdmin

Docs: SetGroupAdmin, RemoveAdmin

public function setGroupAdmin(string $groupId, string $participantChatId): stdClass
public function removeAdmin(string $groupId, string $participantChatId): stdClass

setGroupPicture

Docs: https://green-api.com/en/docs/api/groups/SetGroupPicture/

public function setGroupPicture(string $groupId, string $path): stdClass

Local file path; SDK uploads as JPEG form-data.


leaveGroup

Docs: https://green-api.com/en/docs/api/groups/LeaveGroup/

public function leaveGroup(string $groupId): stdClass

Current account leaves the group.


Example

$create = $greenApi->groups->createGroup('Team', ['79876543210@c.us']);
if ($create->code === 200 && $create->data->created) {
    $groupId = $create->data->chatId;
    $greenApi->sending->sendMessage($groupId, 'Hello group');
    $greenApi->groups->getGroupData($groupId);
}

Not in this SDK

  • updateGroupSettings (exists in docs, not in PHP Groups.php)