WebService::Slack::WebApi - a simple wrapper for Slack Web API
use WebService::Slack::WebApi; # the token is required unless using $slack->oauth->access my $slack = WebService::Slack::WebApi->new(token => 'access token'); # getting channel's descriptions my $channels = $slack->channels->list; # posting message to specified channel and getting message description my $posted_message = $slack->chat->post_message( channel => 'channel id', # required text => 'hoge', # required (not required if 'attachments' argument exists) username => 'fuga', # optional # other optional parameters... );
WebService::Slack::WebApi is a simple wrapper for Slack Web API (https://api.slack.com/web).
You can set some options by giving opt parameter to new method. Almost values of opt are gived to Furl#new.
opt
new
Furl#new
WebService::Slack::WebApi->new(token => 'access token', opt => {});
opt can contain env_proxy as boolean value . If env_proxy is true then proxy settings are loaded from $ENV{HTTP_PROXY} and $ENV{NO_PROXY} by calling Furl#env_proxy method. See also https://metacpan.org/pod/Furl#furl-env_proxy.
env_proxy
$ENV{HTTP_PROXY}
$ENV{NO_PROXY}
Furl#env_proxy
This module provides all methods declared in the API reference (https://api.slack.com/methods).
WebService::Slack::WebApi::Namespace::method_name corresponds to namespace.methodName in Slack Web API. For example WebService::Slack::WebApi::Chat::post_message corresponds to chat.postMessage. You describe as below to call Chat::post_message method.
WebService::Slack::WebApi::Namespace::method_name
namespace.methodName
WebService::Slack::WebApi::Chat::post_message
chat.postMessage
Chat::post_message
my $result = $slack->chat->post_message;
All methods return HashRef. When you want to know what is contained in HashRef, see the API reference.
The API reference shows chat.update method require 4 parameters: token, ts, channel and text. When using this module token parameter is added implicitly except using oauth.access method. So you pass the other 3 parameters to Chat::update method as shown below.
chat.update
token
ts
channel
text
oauth.access
Chat::update
my $result = $slack->chat->update( ts => '1401383885.000061', # as Str channel => 'channel id', text => 'hoge', );
Some methods have optional parameters. If a parameter is optional in the API reference, it is also optional in this module.
These parameters are not primitive:
files.upload.file
files.upload.channels
Mihyaeru/mihyaeru21 <mihyaeru21@gmail.com>
Copyright (C) Mihyaeru/mihyaeru21
Released under the MIT license.
See LICENSE file.
LICENSE
To install WebService::Slack::WebApi, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::Slack::WebApi
CPAN shell
perl -MCPAN -e shell install WebService::Slack::WebApi
For more information on module installation, please visit the detailed CPAN module installation guide.