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

Latest commit

 

History

History
37 lines (27 loc) · 1.41 KB

files-upload.md

File metadata and controls

37 lines (27 loc) · 1.41 KB

files.upload

This method allows you to create or upload an existing file.

Official documentation https://api.slack.com/methods/files.upload
Payload class FilesUploadPayload
PayloadResponse class FilesUploadPayloadResponse

Usage

$apiClient = new ApiClient('your-slack-token-here');

$payload = new FilesUploadPayload();
$payload->setContent('fake content');
$payload->setFilename('acme_file.txt');
$payload->setFileType('text/plain');
$payload->setTitle('Acme File');
$payload->setChannels(['C1234567']);

$response = $apiClient->send($payload);

if ($response->isOk()) {
    // the user belonging to the token has joined the channel
} 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();
}