WebSer...:WebApi(3pm)
π NAME π
Okay so this page is WebSer...:WebApi(3pm) from User Contributed Perl Documentation, and it's all about WebService::Slack::WebApi β a simple wrapper for Slack Web API. π
β¨ SYNOPSIS β¨
Bestie, here's the whole vibe in code:
use WebService::Slack::WebApi;
# By default we use the HTTP client library Furl but you can also use any other
# Eg. LWP::UserAgent
my $slack = WebService::Slack::WebApi->new( ua => LWP::UserAgent->new() );
# 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->conversations->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...
);
πΈ DESCRIPTION πΈ
WebService::Slack::WebApi is literally a simple wrapper for Slack Web API (https://api.slack.com/web). Iconic, honestly. π
π Options π
You can set some options by giving the opt parameter to the new method. Every value inside opt is handed straight to Furl#new. β¨
WebService::Slack::WebApi->new(token => 'access token', opt => {});
π¦ User Agent π¦
By default, WebService::Slack::WebApi uses the Furl HTTP client. But if your software is already using some other client β e.g. LWP::UserAgent or HTTP::Tiny β you can also use that. Under the hood, WebService::Slack::WebApi uses the HTTP client wrapper HTTP::AnyUA. π«Ά
Use the ua parameter to specify the user agent you've already created:
my $ua = LWP::UserAgent->new( timeout => 10 );
my $slack = WebService::Slack::WebApi->new( ua => $ua );
Illegal combo alert! π¨ If you use both parametersuaandopt,WebService::Slack::WebApiwill throw an exception. This combination is illegal. No cap.
π§ Proxy π§
opt can contain env_proxy as a boolean value. If env_proxy is true, then proxy settings are loaded from $ENV{HTTP_PROXY} and $ENV{NO_PROXY} by calling the Furl#env_proxy method. See also https://metacpan.org/pod/Furl#furl-env_proxy. π
π METHODS π
This module provides all methods declared in the API reference (https://api.slack.com/methods). Yes bestie, all of them. π
π Basis π
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 it like this to call the Chat::post_message method:
my $result = $slack->chat->post_message;
π Return value π
All methods return HashRef. When you want to know what is contained in HashRef, see the API reference. That's the whole tea. β
π The token parameter π
The API reference shows chat.update method require 4 parameters: token, ts, channel and text. When using this module, the token parameter is added implicitly except when using the oauth.access method. So you pass the other 3 parameters to the Chat::update method as shown below:
my $result = $slack->chat->update(
ts => '1401383885.000061', # as Str
channel => 'channel id',
text => 'hoge',
);
π Optional parameters π
Some methods have optional parameters. If a parameter is optional in the API reference, it is also optional in this module. Easy peasy. β¨
π Not primitive parameters π
These parameters are not primitive:
files.upload.file: string of path to local filefiles.upload.channels: ArrayRef of channel id string
π¦ SEE ALSO π¦
π AUTHOR π
Mihyaeru/mihyaeru21 <mihyaeru21@gmail.com>
π LICENSE π
Copyright (C) Mihyaeru/mihyaeru21
Released under the MIT license.
See the LICENSE file.
Source/version/date tea, bestie β: this is perl v5.42.2, dated 2025-11-20, and the manual is WebSer...:WebApi(3pm). Bye, go slay those API calls! π
β¨π
π¦ where this page comes from
- alpine 3.24: perl-webservice-slack-webapi-doc 0.19-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms