{"id":15714443,"url":"https://github.com/testmonitor/slack-client","last_synced_at":"2025-05-12T21:22:35.241Z","repository":{"id":43258523,"uuid":"401647581","full_name":"testmonitor/slack-client","owner":"testmonitor","description":"The TestMonitor Slack client.","archived":false,"fork":false,"pushed_at":"2024-10-07T07:50:55.000Z","size":67,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T18:38:42.253Z","etag":null,"topics":["slack","testmonitor"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/testmonitor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-31T09:35:21.000Z","updated_at":"2024-10-07T07:51:00.000Z","dependencies_parsed_at":"2024-08-15T08:42:47.202Z","dependency_job_id":"85438df7-9a16-463f-9a3d-f1ac27f8e436","html_url":"https://github.com/testmonitor/slack-client","commit_stats":{"total_commits":42,"total_committers":4,"mean_commits":10.5,"dds":"0.47619047619047616","last_synced_commit":"0da0f5eb64caf3aff6ccc97d04ff7c60f381465c"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testmonitor%2Fslack-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testmonitor%2Fslack-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testmonitor%2Fslack-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testmonitor%2Fslack-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/testmonitor","download_url":"https://codeload.github.com/testmonitor/slack-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253823723,"owners_count":21969898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["slack","testmonitor"],"created_at":"2024-10-03T21:37:10.071Z","updated_at":"2025-05-12T21:22:35.224Z","avatar_url":"https://github.com/testmonitor.png","language":"PHP","readme":"# TestMonitor Slack Client\n\n[![Latest Stable Version](https://poser.pugx.org/testmonitor/slack-client/v/stable)](https://packagist.org/packages/testmonitor/slack-client)\n[![CircleCI](https://img.shields.io/circleci/project/github/testmonitor/slack-client.svg)](https://circleci.com/gh/testmonitor/slack-client)\n[![StyleCI](https://styleci.io/repos/401647581/shield)](https://styleci.io/repos/401647581)\n[![codecov](https://codecov.io/gh/testmonitor/slack-client/graph/badge.svg?token=6Z5QIYSQ6R)](https://codecov.io/gh/testmonitor/slack-client)\n[![License](https://poser.pugx.org/testmonitor/slack-client/license)](https://packagist.org/packages/testmonitor/slack-client)\n\nThis package provides a very basic, convenient, and unified wrapper for sending posts to Slack.\nOut of the box, it comes with:\n- Slack V2 OAuth 2.0 protocol for authentication (inspired by the [Slack Provider for OAuth 2.0 Client](https://github.com/adam-paterson/oauth2-slack)).\n- The [Slack Block Kit for PHP](https://github.com/slack-php/slack-php-block-kit), a library that provides an OOP interface in PHP for composing messages/modals.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Examples](#examples)\n- [Tests](#tests)\n- [Changelog](#changelog)\n- [Contributing](#contributing)\n- [Credits](#credits)\n- [License](#license)\n\n## Installation\n\nTo install the client you need to require the package using composer:\n\n\t$ composer require testmonitor/slack-client\n\nUse composer's autoload:\n\n```php\nrequire __DIR__.'/../vendor/autoload.php';\n```\n\nYou're all set up now!\n\n## Usage\n\nThis client only supports **oAuth 2.0 authentication**. You'll need a Slack application to proceed. If you haven't done so,\nplease read up with the [Slack authentication API docs](https://api.slack.com/authentication) on how\nto create an application.\n\nWhen you already have an application available, make sure it's a new Slack app, as this package does not\nsupport Slack classic apps. To learn more about the differences between classic and new Slack apps, refer\nto the [differences between old and new Slack apps](https://api.slack.com/authentication/quickstart).\n\nWhen your Slack application is up and running, start with the oAuth authorization:\n\n```php\n$oauth = [\n    'clientId' =\u003e '12345',\n    'clientSecret' =\u003e 'abcdef',\n    'redirectUri' =\u003e 'https://redirect.myapp.com/',\n];\n\n$slack = new \\TestMonitor\\Slack\\Client($oauth);\n\nheader('Location: ' . $slack-\u003eauthorizationUrl('incoming-webhook', 'state'));\nexit();\n```\n\nThis will redirect the user to a page asking confirmation for your app getting access to Slack. Make sure your redirectUrl points\nback to your app. Slack will provide you with a temporary code that allows you to create an access code that can be used for\nauthentication. Route the redirect URL to the following code:\n\n```php\n$oauth = [\n    'clientId' =\u003e '12345',\n    'clientSecret' =\u003e 'abcdef',\n    'redirectUri' =\u003e 'https://redirect.myapp.com/',\n];\n\n$slack = new \\TestMonitor\\Slack\\Client($oauth);\n\n$token = $slack-\u003efetchToken($_REQUEST['code']);\n```\n\nWhen everything went ok, you should have an access token (available through AccessToken object). The AccessToken contains\nall the information you should need to post a message using a webhook:\n\n```php\nvar_dump ($token-\u003egetValues());\n\narray() {\n    [\"ok\"] =\u003e true\n    [\"app_id\"] =\u003e \"APPID\"\n    [\"authed_user\"] =\u003e array(1) {}\n    [\"scope\"] =\u003e \"incoming-webhook\"\n    [\"token_type\"] =\u003e \"bot\"\n    [\"bot_user_id\"] =\u003e \"USERID\"\n    [\"team\"] =\u003e array(2) {}\n    [\"enterprise\"] =\u003e null\n    [\"is_enterprise_install\"] =\u003e false\n    [\"incoming_webhook\"] =\u003e array(4) {\n      [\"channel\"] =\u003e \"#testmonitor\"\n      [\"channel_id\"] =\u003e \"CHANNELID\"\n      [\"configuration_url\"] =\u003e \"https://domain.slack.com/services/B123456USA\"\n      [\"url\"] =\u003e \"https://hooks.slack.com/services/T123456/B123456USA/tEsTm0n1t0r\"\n    }\n```\n\nMake sure to save incoming webhook URL in your database, you'll need this later to post messages.\n\nIn case your Slack app is not configured for token rotation, you're all done now!\n\nWhen token rotation has been enabled, your access token will be valid for **twelve hours**. After that, you'll have to refresh\nthe token to regain access:\n\n```php\n$oauth = ['clientId' =\u003e '12345', 'clientSecret' =\u003e 'abcdef', 'redirectUri' =\u003e 'https://redirect.myapp.com/'];\n$token = new \\TestMonitor\\Slack\\Token('eyJ0...', '0/34ccc...', 1574600877); // the token you got last time\n\n$slack = new \\TestMonitor\\Slack\\Client($oauth, $token);\n\nif ($token-\u003eexpired()) {\n    $newToken = $slack-\u003erefreshToken();\n}\n```\n\nThe new token will be valid again for the next twelve hours.\n\n## Examples\n\nPost a simple message to Slack:\n\n```php\n$message = Kit::newMessage()-\u003etext('Hello world!');\n\n$slack-\u003epostMessage('https://webhook.url/', $message);\n```\n\nBlock Kit allows you to create way more comprehensive messages. Here's another example:\n\n```php\n$user = (object) ['name' =\u003e 'John Doe'];\n\n$message = Kit::newMessage()\n    -\u003etap(function (Message $message) {\n        $message-\u003enewSection()\n            -\u003emrkdwnText(\"*{$user-\u003ename}* created a new issue\");\n    })\n    -\u003edivider()\n    -\u003etap(function (Message $message) {\n        $message-\u003enewContext()\n            -\u003emrkdwnText('Status: *Open*')\n            -\u003emrkdwnText('Priority: *High*')\n            -\u003emrkdwnText('Resolution: *Unresolved*');\n    })\n\n$slack-\u003epostMessage('https://webhook.url/', $message);\n```\n\nFor more information on composing messages with Block Kit, head over to the [Slack Block Kit\nfor PHP documentation](https://github.com/slack-php/slack-php-block-kit) or refer to the\nofficial [Slack Block Kit documentation](https://api.slack.com/block-kit).\n\n## Tests\n\nThe package contains integration tests. You can run them using PHPUnit.\n\n    $ vendor/bin/phpunit\n\n## Changelog\n\nRefer to [CHANGELOG](CHANGELOG.md) for more information.\n\n## Contributing\n\nRefer to [CONTRIBUTING](CONTRIBUTING.md) for contributing details.\n\n## Credits\n\n* **Thijs Kok** - *Lead developer* - [ThijsKok](https://github.com/thijskok)\n* **Stephan Grootveld** - *Developer* - [Stefanius](https://github.com/stefanius)\n* **Frank Keulen** - *Developer* - [FrankIsGek](https://github.com/frankisgek)\n* **Muriel Nooder** - *Developer* - [ThaNoodle](https://github.com/thanoodle)\n\n## License\n\nThe MIT License (MIT). Refer to the [License](LICENSE.md) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestmonitor%2Fslack-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftestmonitor%2Fslack-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftestmonitor%2Fslack-client/lists"}