Overview
  • Namespace
  • Class

Namespaces

  • Slack
    • Message

Classes

  • ApiClient
  • Bot
  • Channel
  • ClientObject
  • DataObject
  • DirectMessageChannel
  • Group
  • Payload
  • RealTimeClient
  • Team
  • User

Interfaces

  • ChannelInterface
  • Exception

Exceptions

  • ApiException
  • ConnectionException
  • UserNotFoundException

Class ApiClient

A client for connecting to the Slack Web API and calling remote API methods.

Direct known subclasses

Slack\RealTimeClient

Namespace: Slack
Located at ApiClient.php

Methods summary

public
# __construct( React\EventLoop\LoopInterface $loop, GuzzleHttp\ClientInterface $httpClient = null )

Creates a new API client instance.

Creates a new API client instance.

Parameters

$loop

$httpClient A Guzzle client instance to send requests with.

$httpClient
public
# setToken( string $token )

Sets the Slack API token to be used during method calls.

Sets the Slack API token to be used during method calls.

Parameters

$token
The API token string.
public Slack\Message\MessageBuilder
# getMessageBuilder( )

Gets a message builder for creating a new message object.

Gets a message builder for creating a new message object.

Returns

Slack\Message\MessageBuilder
public React\Promise\PromiseInterface
# getAuthedUser( )

Gets the currently authenticated user.

Gets the currently authenticated user.

Returns

React\Promise\PromiseInterface
A promise for the currently authenticated user.
public React\Promise\PromiseInterface
# getTeam( )

Gets information about the current Slack team logged in to.

Gets information about the current Slack team logged in to.

Returns

React\Promise\PromiseInterface
A promise for the current Slack team.
public React\Promise\PromiseInterface
# getChannelGroupOrDMByID( string $id )

Gets a channel, group, or DM channel by ID.

Gets a channel, group, or DM channel by ID.

Parameters

$id
The channel ID.

Returns

React\Promise\PromiseInterface
A promise for a channel interface.
public React\Promise\PromiseInterface
# getChannels( )

Gets all channels in the team.

Gets all channels in the team.

Returns

React\Promise\PromiseInterface
public React\Promise\PromiseInterface
# getChannelById( string $id )

Gets a channel by its ID.

Gets a channel by its ID.

Parameters

$id
A channel ID.

Returns

React\Promise\PromiseInterface
A promise for a channel object.
public React\Promise\PromiseInterface
# getChannelByName( string $name )

Gets a channel by its name.

Gets a channel by its name.

Parameters

$name
The name of the channel.

Returns

React\Promise\PromiseInterface
public React\Promise\PromiseInterface
# getGroups( )

Gets all groups the authenticated user is a member of.

Gets all groups the authenticated user is a member of.

Returns

React\Promise\PromiseInterface
public React\Promise\PromiseInterface
# getGroupById( string $id )

Gets a group by its ID.

Gets a group by its ID.

Parameters

$id
A group ID.

Returns

React\Promise\PromiseInterface
A promise for a group object.
public React\Promise\PromiseInterface
# getGroupByName( string $name )

Gets a group by its name.

Gets a group by its name.

Parameters

$name
The name of the group.

Returns

React\Promise\PromiseInterface
public React\Promise\PromiseInterface
# getDMs( )

Gets all DMs the authenticated user has.

Gets all DMs the authenticated user has.

Returns

React\Promise\PromiseInterface
public React\Promise\PromiseInterface
# getDMById( string $id )

Gets a direct message channel by its ID.

Gets a direct message channel by its ID.

Parameters

$id
A DM channel ID.

Returns

React\Promise\PromiseInterface
A promise for a DM object.
public React\Promise\PromiseInterface
# getDMByUser( Slack\User $user )

Gets a direct message channel for a given user.

Gets a direct message channel for a given user.

Parameters

$user
The user to get a DM for.

Returns

React\Promise\PromiseInterface
A promise for a DM object.
public React\Promise\PromiseInterface
# getDMByUserId( string $id )

Gets a direct message channel by user's ID.

Gets a direct message channel by user's ID.

Parameters

$id
A user ID.

Returns

React\Promise\PromiseInterface
A promise for a DM object.
public React\Promise\PromiseInterface
# getUsers( )

Gets all users in the Slack team.

Gets all users in the Slack team.

Returns

React\Promise\PromiseInterface
A promise for an array of users.
public React\Promise\PromiseInterface
# getUserById( string $id )

Gets a user by its ID.

Gets a user by its ID.

Parameters

$id
A user ID.

Returns

React\Promise\PromiseInterface
A promise for a user object.
public React\Promise\PromiseInterface
# getUserByName( $username )

Gets a user by username.

Gets a user by username.

If the user could not be found, the returned promise is rejected with a UserNotFoundException exception.

Returns

React\Promise\PromiseInterface
A promise for a user object.
public React\Promise\PromiseInterface
# send( string $text, Slack\ChannelInterface $channel )

Sends a regular text message to a given channel.

Sends a regular text message to a given channel.

Parameters

$text
The message text.
$channel
The channel to send the message to.

Returns

React\Promise\PromiseInterface
public React\Promise\PromiseInterface
# postMessage( Slack\Message\Message $message )

Posts a message.

Posts a message.

Parameters

$message
The message to post.

Returns

React\Promise\PromiseInterface
public React\Promise\PromiseInterface
# apiCall( string $method, array $args = [] )

Sends an API request.

Sends an API request.

Parameters

$method
The API method to call.
$args

An associative array of arguments to pass to the method call.

Returns

React\Promise\PromiseInterface
A promise for an API response.

Constants summary

string BASE_URL

The base URL for API requests.

The base URL for API requests.

# 'https://slack.com/api/'

Properties summary

protected string $token

The Slack API token string.

The Slack API token string.

#
protected GuzzleHttp\ClientInterface $httpClient

A Guzzle HTTP client.

A Guzzle HTTP client.

#
protected React\EventLoop\LoopInterface $loop

An event loop instance.

An event loop instance.

#
API documentation generated by ApiGen