WebSer...:WebApi(3pm)

πŸ“¦ version 0.19, in alpine 3.24

πŸ’– 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 parameters ua and opt, WebService::Slack::WebApi will 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 file
  • files.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