Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Latest commit

 

History

History
35 lines (26 loc) · 1.46 KB

groups-invite.md

File metadata and controls

35 lines (26 loc) · 1.46 KB

groups.invite

Invites a user to a group. The token's user must be a member of the group.

Official documentation https://api.slack.com/methods/groups.invite
Payload class GroupsInvitePayload
PayloadResponse class GroupsInvitePayloadResponse

Usage

$payload = new GroupsInvitePayload();
$payload->setGroupId('C1234567');
$payload->setUserId('U1234567');

$apiClient = new ApiClient('your-slack-token-here');
$response  = $apiClient->send($payload);

if ($response->isOk()) {
    // user has been successfully invited!
    $response->getGroup(); // the Group object that the user whas invited into
    $response->alreadyInGroup(); // true if the user is already in the group (no operation done)
} else {
    // something went wrong, but what?
    
    // simple error (Slack's error message)
    echo $response->getError();
    
    // explained error (Slack's explanation of the error, according to the documentation)
    echo $response->getErrorExplanation();
}