Code Monkey home page Code Monkey logo

slack-php-api's Introduction

A PHP client for Slack's API

There is a bunch of existing PHP clients for Slack. But some are not up-to-date or miss features, some only cover a small part of the API and most are simply no longer maintained.

This SDK is generated automatically with JanePHP from the official Slack API specs.

It also provides a full object-oriented interface for all the endpoints, requests and responses of the Slack Web API.

Installation

This library is built atop of PSR-7 and PSR-18. So you will need to install some implementations for those standard interfaces.

If no PSR-18 client or PSR-7 message factory is available yet in your project or you don't know or don't care which one to use, just install some default:

composer require symfony/http-client nyholm/psr7

You can now install the Slack client:

composer require jolicode/slack-php-api

Quick start

// $client contains all the methods to interact with the API
$client = JoliCode\Slack\ClientFactory::create($yourSlackToken);

$user = $client->usersInfo(['user' => 'U123AZER'])->getUser();

Documentation

Want more documentation or examples? See the full documentation here.

Further documentation

You can see the current and past versions using one of the following:

Finally, some meta documentation:

License

This library is licensed under the MIT License - see the LICENSE file for details.

slack-php-api's People

Contributors

atymic avatar binoculars88 avatar damienalexandre avatar dredav avatar jeremeamia avatar korbeil avatar lyrixx avatar matthewhallcom avatar matthewnessworthy avatar mihani avatar mpyw avatar pyrech avatar samnela avatar simonschaufi avatar tchapuis avatar ternel avatar xavierlacot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slack-php-api's Issues

Fatal error on chatPostMessage

Hello,

since today, we get the following error, if we want to send a message over chatPostMessage:
Fatal error: Declaration of JoliCode\Slack\Api\Endpoint\ChatPostMessage::getBody(Symfony\Component\Serializer\SerializerInterface $serializer, ?Http\Message\StreamFactory $streamFactory = NULL): array must be compatible with Jane\OpenApiRuntime\Client\BaseEndpoint::getBody(Symfony\Component\Serializer\SerializerInterface $serializer, $streamFactory = NULL): array

The code is the following:
$client = JoliCode\Slack\ClientFactory::create(SLACK_OAUTH_TOKEN);

        $result = $client->chatPostMessage([
            'username' => $username,
            'channel' => $channel,
            'text' => $text,
        ]);

Parameters for chatDeleteScheduledMessage

Hello,

i wanted to delete a scheduled Chatmessage, but the Method chatDeleteScheduledMessage got only one string Param (string $fetch). How can i set the param like the scheduledMessageId and the channelid? I need both of them to delete the Message in Slack.

Greetings

Method chatPostMessage() with "blocks" return "invalid_blocks_format"

Lib version: v4.1.1
PHP: 7.4.16

Hi, your lib is great! But i have problem with sending Blocks with chatPostMessage() method. I am trying everything and it does not work. I get response invalid_blocks_format from Slack.

My code looks like this:

$client->chatPostMessage([
            'channel' => '#channel',
            'username' => 'BOT',
            'blocks' => <<<EOT
{
	"blocks": [
		{
			"type": "section",
			"text": {
				"type": "plain_text",
				"text": "This is a plain text section block.",
				"emoji": true
			}
		}
	]
}
EOT]);

Could you check if everything is working properly?

chatUpdate -> 'ts' requiring float that PHP can never satisfy

PHP will never be able to satisfy this float
1562189704.014800

Sending Slack a string of "1562189704.014800" works perfectly fine.

PHP literally does not have the ability to maintain 1562189704.014800 as a float. It will always remove the trailing zeros unless its a string.

$optionsResolver->setAllowedTypes('text', ['float']);

should be

$optionsResolver->setAllowedTypes('text', ['string']);

If this already exists in a newer version please let me know. Thanks for an awesome tool by the way!

Incompatible with PHP 8

From what I understand, this is currently incompatible with PHP 8.
This should probably be noted in the composer.json rather soonish right?

Example error:

PHP Fatal error:  Declaration of JoliCode\Slack\Api\Endpoint\ChatPostMessage::transformResponseBody(string $body, int $status, Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType) must be compatible with Jane\OpenApiRuntime\Client\EndpointTrait::transformResponseBody(string $body, int $status, Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) in โ€ฆ/vendor/jolicode/slack-php-api/generated/Endpoint/ChatPostMessage.php on line 119

From what I understand, the problem is that in one place it says string $contentType = null whereas in the other place it says ?string $contentType.

I looked a minute at how the code generation works but realized that I would need to dig into this in more detail in order to fix it, and probably it's an easy fix for you.

I will create a PR for an adjustment I made in the generated code. No hard feelings if you just decline it (because, who edits generated code, right?. But this way I can at least offer you a bit more than just a bug report.

I wish you a Merry Christmas! ๐ŸŽ„

Pagination

Hey ๐Ÿ‘‹

Your library is awesome, but one thing that seems to be missing is pagination.
I'm working with pretty large slack teams (over 10k members), so I need to use the cursor based pagination pretty often.

I was wondering if you had plans on adding an abstraction around the pagination.

I'd be happy to have a go if you are keen :)

Thanks!

Issue with declaration of JaneObjectNormalizer

Hello,
I've tried to send test message to a channel but i've got an error:

$client = SlackFactory::create('my-token');
$this->client->chatPostMessage([
            'username' => 'example bot',
            'channel' => 'test-integration-channel',
            'text' => 'Hello world',
        ]); 

Declaration of JoliCode\Slack\Api\Normalizer\JaneObjectNormalizer::denormalize($data, $class, $format = NULL, array $context = Array) must be compatible with Symfony\Component\Serializer\Normalizer\DenormalizerInterface::denormalize($data, string $type, ?string $format = NULL, array $context = Array) in /app/vendor/jolicode/slack-php-api/generated/Normalizer/JaneObjectNormalizer.php:24

I looked into JaneObjectNormalizer https://github.com/jolicode/slack-php-api/blob/master/generated/Normalizer/JaneObjectNormalizer.php#L50
and DenormalizerInterface https://github.com/symfony/serializer/blob/5.x/Normalizer/DenormalizerInterface.php#L45
and it looks like their declarations are really different. Is this a bug?

long chat message throws an Exception

Hi, we have been using this really super working library for some time. However, today we noticed that for very long messages sent with the chatPostMessage function, an error is thrown with the content isfile(): File name is longer than the maximum allowed path length on this platform (4096):.
Do you guys have any idea how I can solve this problem?
File: /vendor/jane-php/open-api-runtime/Client/Psr18Client.php
Function: executePsr7Endpoint

Can't install project

I'm just following the instructions in the readme

composer require php-http/curl-client guzzlehttp/psr7
composer require jolicode/slack-php-api
 [InvalidArgumentException]
  Could not find a version of package jolicode/slack-php-api matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.

Php version is

PHP 7.1.1-1+deb.sury.org~trusty+1 (cli) (built: Jan 20 2017 09:43:29) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.1-1+deb.sury.org~trusty+1, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans

chatPostMessage Interactive Buttons

trying to send buttons as messages, but nothing happens.
Code is based off of the example [https://api.slack.com/reference/block-kit/block-elements#button]
$result = $client->chatPostMessage([ 'username' => 'Bot', 'channel' => 'general', 'text' => 'Hello', 'blocks' => json_encode([ [ "type"=> "button", "text"=> [ "type"=> "plain_text", "text"=> "Click Me" ], "value"=> "click_me_123", "action_id"=> "button" ]) ] ]);

Request-URI Too Large

Some API methods such as views.publish require a large payload and as a result - can fail with Request-URI Too Large. Is there a way to have the client send as HTTP POST with either form values or JSON encoded body? Slack API supports both of these options. Using the Slack Web API

Support for views.open

Awesome package. Love it.

It would be great to have support for block surface triggers.

Eg. views.open

ChatUpdate Endpoint - Replace float TS by string TS

Hello,

When I used this lib to update an slack message I found an issue. In JoliCode\Slack\Api\Endpoint\ChatUpdate, getFormOptionsResolver allow a float for the Slack TS then I read the slack api doc Slack TS is a string.

To fix this issue I override

        $optionsResolver->setAllowedTypes('ts', ['float']);

by

        $optionsResolver->setAllowedTypes('ts', ['string']);

After then it's works but I don't know if there are BC somewhere.

Milestone: Create new release

As there is changes in the repo, when you're done with changes, please create new release tag, so we can use it in the composer.

Type hint on @return is confusing

As an example, below is the type hint for users.lookupByEmail

    /**
     * Find a user with an email address.
     *
     * @param array $queryParameters {
     *
     *     @var string $email An email address belonging to a user in the workspace
     *     @var string $token Authentication token. Requires scope: `users:read.email`
     * }
     *
     * @param string $fetch Fetch mode to use (can be OBJECT or RESPONSE)
     *
     * @return \JoliCode\Slack\Api\Model\UsersLookupByEmailGetResponse200|\JoliCode\Slack\Api\Model\UsersLookupByEmailGetResponsedefault|\Psr\Http\Message\ResponseInterface|null
     */
    public function usersLookupByEmail(array $queryParameters = [], string $fetch = self::FETCH_OBJECT)

However, it appears to be incorrect. I cannot see any instance where it would return ResponseInterface? Nor can I see any instance where it would return UsersLookupByEmailGetResponsedefault - indeed it seems that this is the result of calling getResponse() on a SlackErrorResponse exception. So indeed a @throws is missing perhaps.

Main issue is this causes significant issues with static analysis tooling because it believes the code is not properly handling the possible return types - for example it doesn't realise that UsersLookupByEmailGetResponsedefault will never be returned (which does not contain a getUser method) - nor that ResponseInterface will never be returned. Thus code becomes more complex or when somebody realises it's a false positive due to incorrect PHPDoc it causes lots of ignores.

Example in my case is with phpstan but I would guess would be the same for other tools like psalm too.

I guess this is perhaps caused by the Jane code generation but thought I'd just drop it here as perhaps there is a way to make it work. Removing the UsersLookupByEmailGetResponsedefault from the schema is one option and just having UsersLookupByEmailGetResponse200 the default one with all the fields - as you can still check the OK parameters and throw and use the same object - since the 200 has the user as nullable anyway. Though I guess that nullable technically is not the case for a successful response.

So yeh, interesting.

Cannot install (problem with composer on PHP 7.2)

Hi, I tried running your suggested composer commands, but when I open vendor/autoload.php, I get this:

[25-Mar-2019 18:10:12 UTC] PHP Fatal error:  Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors
 - Puli Factory is not available
 - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: .
 - No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\ResponseFactory, Http\Factory\Diactoros\ResponseFactory, Http\Factory\Guzzle\ResponseFactory, Http\Factory\Slim\ResponseFactory.

 in /home/mgtckfyeswfr/apis/slack/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41
Stack trace:
#0 /home/mgtckfyeswfr/apis/slack/vendor/php-http/discovery/src/ClassDiscovery.php(79): Http\Discovery\Exception\DiscoveryFailedException::create(Array)
#1 /home/mgtckfyeswfr/apis/slack/vendor/php-http/discovery/src/Psr17Factory in /home/mgtckfyeswfr/apis/slack/vendor/php-http/discovery/src/ClassDiscovery.php on line 210

I am running PHP 7.2. I looked at this link: http://docs.php-http.org/en/latest/discovery.html#common-errors and tried installing all the packages it mentions, but when I try the Puli install:

composer require puli/composer-plugin

i get this:

[InvalidArgumentException]                    
  Could not find package puli/composer-plugin.  
                                                
  Did you mean this?                            
      puli/composer-plugin

it looks like a full stop is somehow being added to the end of the word plugin?

Can you help?

Upload files to Slack

Currently trying to figure out a way to upload image files using this library. I'm using 1.2.1 due to #57

I'm able to get text snippets to upload correctly, however, I cannot get a PNG image to upload.

A few variations of what I've tried:

        $image = $progressBarUtil->getImage();
        $tmp = tempnam(sys_get_temp_dir(), 'tmp');
        $fh = fopen($tmp, 'w+');
        fwrite($fh, $image);
        fclose($fh);

        $upload = $this->getBotApi()->filesUpload([
            'channels' => $channelId,
            'file' => $tmp,
            'filename' => 'image.png',
            'filetype' => 'png,
        ]);

and

        $image = $progressBarUtil->getImage();

        $upload = $this->getBotApi()->filesUpload([
            'channels' => $channelId,
            'file' => $image,
            'filename' => 'image.png',
            'filetype' => 'png',
        ]);

the $channelId variable is correctly defined, I've just excluded it here.

Everything I try I get a no_file_data error

How to properly upgrade `as_user` in v3?

Hey there!

Glad to see this package being worked on and some updates in v3. Thanks for the contributions ๐Ÿ‘

I'm confused about the change to as_user:

  • In the release notes all it says is Breaking Some options have new types, for example ChatUpdate as_user option was a boolean and is now a string
  • The inline docs in generated/Endpoint/ChatPostMessage.php do hint it as a string, but the description still describes it as a boolean, @var string $as_user Pass true to post the message as the authed user, instead of as a bot. Defaults to false. See [authorship](#authorship) below.
  • The slack docs still say that it should be a Boolean https://api.slack.com/methods/chat.postMessage#arg_as_user

I don't follow the change or understand why it was changed. I tried to search for any meaningful commit about this in the repo but didn't see anything relevant either. Can you please explain the change and explain what I should be passing into it to keep the previous behaviour the same (I was previously passing in as_user => true to send DMs on behalf of users)? Is it now expecting the string 'true'?

Thanks so much!

Crash on PHP8

I'm seeing this error on PHP8:

PHP Fatal error:  Declaration of JoliCode\Slack\Api\Endpoint\ChatPostMessage::transformResponseBody(string $body, int $status, Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType) must be compatible with Jane\OpenApiRuntime\Client\EndpointTrait::transformResponseBody(string $body, int $status, Symfony\Component\Serializer\SerializerInterface $serializer, ?string $contentType = null) in /opt/prs-pinger/vendor/jolicode/slack-php-api/generated/Endpoint/ChatPostMessage.php on line 119

I'm running jane-php/open-api-runtime version 6.3.3 and jolicode/slack-php-api version 4.0.0

channelHistory example

I've connected all working but when I try and query channel 200 object but no messages?

$slack_token = "bla";
$slack_uid = "blabla";

$client = ClientFactory::create($slack_token);

$results = $client->channelsHistory(['count' => 100, 'token' => $slack_token, 'channel' => 'Cblabla']);
$messages = $results->getMessages();

print_r($messages);

No way to access OAuth Access Token.

When executing the following code. All I was able to access getOk method, There is no way to access the access token.

$client->oauthAccess([
"redirect_uri" => "/path/to/redirectURI/",
"client_id" => Settings::where('key', 'slack.client.id')->first()->value,
"client_secret" => Settings::where('key', 'slack.client.secret')->first()->value,
"code" => $request->getQueryParams()["code"], 
]);

https://api.slack.com/methods/oauth.access

No text error code?

Anyone know why i'd be getting this error?

JoliCode\Slack\Exception\SlackErrorResponse: Slack returned error code "no_text" in /var/www/vendor/jolicode/slack-php-api/src/HttpPlugin/SlackErrorPlugin.php:36

PHP 7.4.1
jolicode/slack-php-api - v4.1.1

running this code:

    $client = ClientFactory::create(config('services.slack.token'));
    $client->chatPostMessage([
            'channel' => $slack_id,
            'link_names' => true,
            'text' => "Test string"
    ]);

How to get the exact error messages

I want to check the exact error code. This is what I receive as $response when trying to get users list:
$response = $this->slackClient->usersList();

        (
            [cacheTs:protected] => 
            [members:protected] => 
            [ok:protected] => 
            [responseMetadata:protected] => 
            [storage:ArrayObject:private] => Array
                (
                    [error] => invalid_auth
                )

        )```

How should specific errors be handled such as `account_inactive`, `invalid_auth` etc?

Add more examples in the documentation

We should add more documentation.

Maybe take one or two popular endpoints from the API and show the required PHP code to call them, and the proper "dump" of the response. That will show how awesome this library is ๐Ÿ‘

Not compatible with PHP 7

Hi,

I'm trying to install the package with composer, but I'm getting:
Package jolicode/slack-php-api at version has a PHP requirement incompatible with your PHP version (7.0.7)

Thanks

ObjsGroup::setPriority() float given error

Hi. I got the following error while I tried to get private channels (JoliCode\Slack\Api\Endpoint\GroupsList):

Argument 1 passed to JoliCode\Slack\Api\Model\ObjsGroup::setPriority() must be of the type integer or null, float given, called in /var/www/projects/message-bender/web/vendor/jolicode/slack-php-api/generated/Normalizer/ObjsGroupNormalizer.php on line 108

According to coming float value, $priority parameter should accept float value as not like that ObjsGroup::setPriority(?int $priority)

What do you suggest to do workaround solution in quick way (better overriding methods) before fixed?

php-http/discovery fails to find PSR18ClientDiscovery

Code:

<?php 
namespace Spine\Slack\classes;
class UserUpdateEvent{
	public function updated($model){
		$token = \Root3287\models\Settings::where("key", "slack.oauth")->first()->value;
		$client = \JoliCode\Slack\ClientFactory::create($token);
		// $form, Headers
		$error = $client->usersProfileSet([
			"profile" => json_encode([
				"status_text" => $model->status,
				"status_emoji" => $model->status_text,
				"status_expire" => 0
			]),
		]);
	}
}?>

Stacktrace:

Details
Type: Http\Discovery\Exception\ClassInstantiationFailedException
Code: 0
Message: Unexpected exception when instantiating class.
File: /home/timothy/git/Spine/vendor/php-http/discovery/src/ClassDiscovery.php
Line: 210
Trace

#0 /home/timothy/git/Spine/vendor/php-http/discovery/src/Psr18ClientDiscovery.php(30): Http\Discovery\ClassDiscovery::instantiateClass(Array)
#1 /home/timothy/git/Spine/vendor/jolicode/slack-php-api/src/ClientFactory.php(30): Http\Discovery\Psr18ClientDiscovery::find()
#2 /home/timothy/git/Spine/modules/Slack/classes/UserUpdateEvent.php(6): JoliCode\Slack\ClientFactory::create('xoxb-7615521273...')
#3 [internal function]: Spine\Slack\classes\UserUpdateEvent->updated(Object(Root3287\models\Users))

Installed Packages:

almasaeed2010/adminlte                dev-master 0e48302 AdminLTE - admin control panel and dashboard that's based on Bootstrap 4
clue/stream-filter                    v1.4.1             A simple and modern approach to stream filtering in PHP
composer/installers                   v1.7.0             A multi-framework Composer library installer
doctrine/inflector                    1.3.1              Common String Manipulations with regard to casing and singular/plural rules.
duosecurity/duo_php                   1.0.1              A PHP implementation of the Duo Web SDK.
fgrosse/phpasn1                       v2.1.1             A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.
fig/http-message-util                 1.1.3              Utility classes and constants for use with PSR-7 (psr/http-message)
firebase/php-jwt                      v5.0.0             A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
illuminate/container                  v6.11.0            The Illuminate Container package.
illuminate/contracts                  v6.11.0            The Illuminate Contracts package.
illuminate/database                   v6.11.0            The Illuminate Database package.
illuminate/events                     v6.11.0            The Illuminate Events package.
illuminate/support                    v6.11.0            The Illuminate Support package.
jane-php/json-schema-runtime          v4.5.4             Jane runtime Library
jane-php/open-api-runtime             v4.5.4             Jane OpenAPI Runtime Library, dependencies and utility class for a library generated by jane/openapi
jeremeamia/superclosure               2.4.0              Serialize Closure objects, including their context and binding
jolicode/slack-php-api                2.3.0              An up to date PHP client for Slack's API
kanellov/slim-twig-flash              0.2.0              A Twig extension to access Slim Flash messages in templates
league/uri                            5.3.0              URI manipulation library
league/uri-components                 1.8.2              URI components manipulation library
league/uri-hostname-parser            1.1.1              ICANN base hostname parsing implemented in PHP.
league/uri-interfaces                 1.1.1              Common interface for URI representation
league/uri-manipulations              1.5.0              URI manipulation library
league/uri-parser                     1.4.1              userland URI parser RFC 3986 compliant
league/uri-schemes                    1.2.1              URI manipulation library
nesbot/carbon                         2.28.0             An API extension for DateTime that supports 281 different languages.
nikic/fast-route                      v1.3.0             Fast request router for PHP
nikic/php-parser                      v4.3.0             A PHP parser written in PHP
npm-asset/bootstrap                   4.4.1             
npm-asset/bootstrap-icons             1.0.0-alpha2      
npm-asset/bootswatch                  4.4.1             
npm-asset/chart.js                    2.9.3             
npm-asset/chartjs-color               2.4.1             
npm-asset/chartjs-color-string        0.6.0             
npm-asset/color-convert               1.9.3             
npm-asset/color-name                  1.1.3             
npm-asset/font-awesome                5.12.0            
npm-asset/ionicons                    5.0.0-patch15     
npm-asset/jquery                      3.4.1             
npm-asset/moment                      2.24.0            
npm-asset/popper.js                   v2.0.0-patch.17   
npm-asset/toastr                      2.1.4             
oomphinc/composer-installers-extender v1.1.2             Extend the composer/installers plugin to accept any arbitrary package type.
php-di/invoker                        2.0.0              Generic and extensible callable invoker
php-di/php-di                         6.0.11             The dependency injection container for humans
php-di/phpdoc-reader                  2.1.1              PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)
php-http/client-common                2.1.0              Common HTTP Client implementations and tools for HTTPlug
php-http/curl-client                  2.1.0              PSR-18 and HTTPlug Async client with cURL
php-http/discovery                    1.7.4              Finds installed HTTPlug implementations and PSR-7 message factories
php-http/httplug                      2.1.0              HTTPlug, the HTTP client abstraction for PHP
php-http/message                      1.8.0              HTTP Message related tools
php-http/message-factory              v1.0.2             Factory interfaces for PSR-7 HTTP Message
php-http/multipart-stream-builder     1.1.0              A builder class that help you create a multipart stream
php-http/promise                      v1.0.0             Promise used for asynchronous HTTP requests
php-jsonpointer/php-jsonpointer       v3.0.2             Implementation of JSON Pointer (http://tools.ietf.org/html/rfc6901)
psr/cache                             1.0.1              Common interface for caching libraries
psr/container                         1.0.0              Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                  1.0.0              Standard interfaces for event handling.
psr/http-client                       1.0.0              Common interface for HTTP clients
psr/http-factory                      1.0.1              Common interfaces for PSR-7 HTTP message factories
psr/http-message                      1.0.1              Common interface for HTTP messages
psr/http-server-handler               1.0.1              Common interface for HTTP server-side request handler
psr/http-server-middleware            1.0.1              Common interface for HTTP server-side middleware
psr/log                               1.1.2              Common interface for logging libraries
psr/simple-cache                      1.0.1              Common interfaces for simple caching
ralouphie/getallheaders               3.0.3              A polyfill for getallheaders.
slim/csrf                             1.0.0              Slim Framework 4 CSRF protection PSR-15 middleware
slim/flash                            0.4.0              Slim Framework Flash message service provider
slim/psr7                             0.6                Strict PSR-7 implementation
slim/slim                             4.0.0              Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs
slim/twig-view                        3.x-dev 46bc497    Slim Framework 4 view helper built on top of the Twig (2 and 3) templating component
spomky-labs/aes-key-wrap              v5.0.0             AES Key Wrap for PHP.
spomky-labs/base64url                 v2.0.1             Base 64 URL Safe Encoding/Decoding PHP Library
symfony/cache                         v5.0.2             Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts               v2.0.1             Generic abstractions related to caching
symfony/config                        v5.0.2             Symfony Config Component
symfony/console                       v5.0.2             Symfony Console Component
symfony/dependency-injection          v5.0.2             Symfony DependencyInjection Component
symfony/error-handler                 v5.0.2             Symfony ErrorHandler Component
symfony/event-dispatcher              v5.0.2             Symfony EventDispatcher Component
symfony/event-dispatcher-contracts    v2.0.1             Generic abstractions related to dispatching event
symfony/filesystem                    v5.0.2             Symfony Filesystem Component
symfony/finder                        v5.0.2             Symfony Finder Component
symfony/framework-bundle              v5.0.2             Symfony FrameworkBundle
symfony/http-client                   v5.0.2             Symfony HttpClient component
symfony/http-client-contracts         v2.0.1             Generic abstractions related to HTTP clients
symfony/http-foundation               v5.0.2             Symfony HttpFoundation Component
symfony/http-kernel                   v5.0.2             Symfony HttpKernel Component
symfony/mime                          v5.0.2             A library to manipulate MIME messages
symfony/options-resolver              v5.0.2             Symfony OptionsResolver Component
symfony/polyfill-ctype                v1.13.1            Symfony polyfill for ctype functions
symfony/polyfill-intl-idn             v1.13.1            Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-mbstring             v1.13.1            Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                v1.13.1            Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php72                v1.13.1            Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73                v1.13.1            Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-util                 v1.13.1            Symfony utilities for portability of PHP codes
symfony/routing                       v5.0.2             Symfony Routing Component
symfony/serializer                    v5.0.2             Symfony Serializer Component
symfony/service-contracts             v2.0.1             Generic abstractions related to writing services
symfony/translation                   v5.0.2             Symfony Translation Component
symfony/translation-contracts         v2.0.1             Generic abstractions related to translation
symfony/var-dumper                    v5.0.2             Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter                  v5.0.2             A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/yaml                          v5.0.2             Symfony Yaml Component
twig/extensions                       v1.5.4             Common additional features for Twig that do not directly belong in core
twig/twig                             v2.12.3            Twig, the flexible, fast, and secure template language for PHP
web-token/jwt-framework               v2.1.4             JSON Object Signing and Encryption library for PHP and Symfony Bundle.
wikimedia/composer-merge-plugin       v1.4.1             Composer plugin to merge multiple composer.json files

chatPostMessage and attachments

Hello,

First of all, congratulations on the code!

I'm trying to pass an attachment to the Slack message using the chatPostMessage() method but I can't get it through.

I have 2 problems,

  • No matter what I put in $attachments, I get the mistake:
    Slack returned error code "no_text."

  • I don't understand what kind of thong format I'm supposed to fill out? Can you give me an example?

Thank you in advance and have a nice day.

Example has syntax error

Stumbled upon this part in the documentation:

for ($client->iterateUsersList() as $user) {
    $userNames[] = $user->getName();
}

which should probably be:

foreach ($client->iterateUsersList() as $user) {
    $userNames[] = $user->getName();
}

Example of getting error message?

How can I get the error message from response_metadata? All I can see from $e->getMessage() is Slack returned error code "invalid_arguments", but how do I know which arguments?

Scheduling messages expects the post_at attribute to be string while slack returns an integer

When scheduling a message using the following code:

$client->chatScheduleMessage([
    'channel'=> 'testing-slack-apps',
    'text'=> 'Hey, This is a scheduled message :tada:',
    'post_at'=> 1599654720
]);

I got the following error because the package is expecting the post_at attribute to be of type string.
image

so I have changed the post_at attribute to be of type string as follows:

$client->chatScheduleMessage([
    'channel'=> 'testing-slack-apps',
    'text'=> 'Hey, This is a scheduled message :tada:',
    'post_at'=> '1599654720'
]);

now it works and the message gets scheduled successfully, but now another exception is throwed, saying that JoliCode\Slack\Api\Model\ChatScheduleMessagePostResponse200::setPostAt() is expecting the post_at parameter to be of type string, but actually slack returns it as an integer.

image

I believe that it doesn't have to be of type string since slack is expecting it as an integer representing the UNIX timestamp.

Message icons loading problem

After setting icon_url during creating message, slack returns link for image in field image_48 of field icons.
I'm unable to get it via ObjsMessage.

composer won't install dependencies

Using version ^1.7 for php-http/curl-client
Using version ^1.5 for guzzlehttp/psr7
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: don't install php-http/curl-client v1.7.1
- Conclusion: don't install php-http/curl-client v1.7.0|remove php-http/httplug v2.0.0
- Conclusion: don't install php-http/curl-client v1.7.0|don't install php-http/httplug v2.0.0
- Installation request for php-http/curl-client ^1.7 -> satisfiable by php-http/curl-client[v1.7.0, v1.7.1].
- php-http/curl-client v1.7.0 requires php-http/httplug ^1.0 -> satisfiable by php-http/httplug[v1.0.0, v1.1.0].
- Can only install one of: php-http/httplug[v1.0.0, v2.0.0].
- Can only install one of: php-http/httplug[v1.1.0, v2.0.0].
- Installation request for php-http/httplug (locked at v2.0.0) -> satisfiable by php-http/httplug[v2.0.0].

Installation failed, reverting ./composer.json to its original content.

works great docs suck

Hi,

Finally figured it out, I have update the readme on my loocal clone to make it easier to understand, how do I push this raise pull request so you might want this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.