nexylan / slack Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
And fix possible issues.
Tried this way and the same way as your readme (chained with ->from()->to()->send('hi')
)
$client = new Client($slack['endpoint'], [
'username'=>'CRM',
'channel'=>'#activity'
]);
$msg = $client->createMessage();
$msg->from($username);
$msg->to('#'.$channel);
$msg->withIcon($emoji);
$client->sendMessage($msg);
I assume something is working because there's no error, but nothing shows up on slack. I'm verified my endpoint twice and can't figure out what's wrong. Any ideas?
Here's what I get when I var_dump the client after sending the message:
object(Nexy\Slack\Client)#2856 (2) {
["options":"Nexy\Slack\Client":private]=> array(8) {
["channel"]=> string(9) "#activity"
["username"]=> string(3) "CRM"
["icon"]=> NULL
["link_names"]=> bool(false)
["unfurl_links"]=> bool(false)
["unfurl_media"]=> bool(true)
["allow_markdown"]=> bool(true)
["markdown_in_attachments"]=> array(0) { }
}
["httpClient":"Nexy\Slack\Client":private]=> object(Http\Client\Common\HttpMethodsClient)#2866 (2) {
["httpClient":"Http\Client\Common\HttpMethodsClient":private]=> object(Http\Client\Common\PluginClient)#2869 (3) {
["client":"Http\Client\Common\PluginClient":private]=> object(Http\Adapter\Guzzle6\Client)#2874 (1) {
["client":"Http\Adapter\Guzzle6\Client":private]=> object(GuzzleHttp\Client)#2870 (1) {
["config":"GuzzleHttp\Client":private]=> array(7) {
["handler"]=> object(GuzzleHttp\HandlerStack)#2862 (3) {
["handler":"GuzzleHttp\HandlerStack":private]=> object(Closure)#2864 (2) {
["static"]=> array(2) {
["default"]=> object(Closure)#2875 (2) {
["static"]=> array(2) {
["default"]=> object(GuzzleHttp\Handler\CurlMultiHandler)#2873 (5) {
["factory":"GuzzleHttp\Handler\CurlMultiHandler":private]=> object(GuzzleHttp\Handler\CurlFactory)#2863 (2) {
["handles":"GuzzleHttp\Handler\CurlFactory":private]=> array(0) { }
["maxHandles":"GuzzleHttp\Handler\CurlFactory":private]=> int(50) }
["selectTimeout":"GuzzleHttp\Handler\CurlMultiHandler":private]=> int(1)
["active":"GuzzleHttp\Handler\CurlMultiHandler":private]=> NULL
["handles":"GuzzleHttp\Handler\CurlMultiHandler":private]=> array(0) { }
["delays":"GuzzleHttp\Handler\CurlMultiHandler":private]=> array(0) { }
}
["sync"]=> object(GuzzleHttp\Handler\CurlHandler)#2867 (1) {
["factory":"GuzzleHttp\Handler\CurlHandler":private]=> object(GuzzleHttp\Handler\CurlFactory)#2858 (2) {
["handles":"GuzzleHttp\Handler\CurlFactory":private]=> array(0) { }
["maxHandles":"GuzzleHttp\Handler\CurlFactory":private]=> int(3) }
}
}
["parameter"]=> array(2) {
["$request"]=> string(10) ""
["$options"]=> string(10) "" }
}
["streaming"]=> object(GuzzleHttp\Handler\StreamHandler)#2871 (1) {
["lastHeaders":"GuzzleHttp\Handler\StreamHandler":private]=> array(0) { }
}
}
["parameter"]=> array(2) {
["$request"]=> string(10) ""
["$options"]=> string(10) "" }
}
["stack":"GuzzleHttp\HandlerStack":private]=> array(1) {
[0]=> array(2) {
[0]=> object(Closure)#2853 (1) {
["parameter"]=> array(1) {
["$handler"]=> string(10) "" }
} [1]=> string(12) "prepare_body" }
}
["cached":"GuzzleHttp\HandlerStack":private]=> NULL }
["allow_redirects"]=> array(5) {
["max"]=> int(5)
["protocols"]=> array(2) {
[0]=> string(4) "http" [1]=> string(5) "https" }
["strict"]=> bool(false)
["referer"]=> bool(false)
["track_redirects"]=> bool(false) }
["http_errors"]=> bool(true)
["decode_content"]=> bool(true)
["verify"]=> bool(true)
["cookies"]=> bool(false)
["headers"]=> array(1) {
["User-Agent"]=> string(69) "GuzzleHttp/6.3.3 curl/7.47.0 PHP/7.2.8-1+ubuntu16.04.1+deb.sury.org+1" }
}
}
}
["plugins":"Http\Client\Common\PluginClient":private]=> array(1) {
[0]=> object(Http\Client\Common\Plugin\BaseUriPlugin)#2855 (2) {
["addHostPlugin":"Http\Client\Common\Plugin\BaseUriPlugin":private]=> object(Http\Client\Common\Plugin\AddHostPlugin)#2897 (2) {
["host":"Http\Client\Common\Plugin\AddHostPlugin":private]=> object(GuzzleHttp\Psr7\Uri)#2898 (7) {
["scheme":"GuzzleHttp\Psr7\Uri":private]=> string(5) "https"
["userInfo":"GuzzleHttp\Psr7\Uri":private]=> string(0) ""
["host":"GuzzleHttp\Psr7\Uri":private]=> string(15) "hooks.slack.com"
["port":"GuzzleHttp\Psr7\Uri":private]=> NULL
["path":"GuzzleHttp\Psr7\Uri":private]=> string(54) "/services/{{____INFO_HERE_IS_PROBABLY_A_SECURITY_CONCERN_SO_IM_HIDING____}}"
["query":"GuzzleHttp\Psr7\Uri":private]=> string(0) ""
["fragment":"GuzzleHttp\Psr7\Uri":private]=> string(0) "" }
["replace":"Http\Client\Common\Plugin\AddHostPlugin":private]=> bool(false) }
["addPathPlugin":"Http\Client\Common\Plugin\BaseUriPlugin":private]=> object(Http\Client\Common\Plugin\AddPathPlugin)#2896 (1) {
["uri":"Http\Client\Common\Plugin\AddPathPlugin":private]=> object(GuzzleHttp\Psr7\Uri)#2898 (7) {
["scheme":"GuzzleHttp\Psr7\Uri":private]=> string(5) "https"
["userInfo":"GuzzleHttp\Psr7\Uri":private]=> string(0) ""
["host":"GuzzleHttp\Psr7\Uri":private]=> string(15) "hooks.slack.com"
["port":"GuzzleHttp\Psr7\Uri":private]=> NULL
["path":"GuzzleHttp\Psr7\Uri":private]=> string(54) "/services/{{____INFO_HERE_IS_PROBABLY_A_SECURITY_CONCERN_SO_IM_HIDING____}}"
["query":"GuzzleHttp\Psr7\Uri":private]=> string(0) ""
["fragment":"GuzzleHttp\Psr7\Uri":private]=> string(0) "" }
}
}
}
["options":"Http\Client\Common\PluginClient":private]=> array(2) {
["max_restarts"]=> int(10)
["debug_plugins"]=> array(0) { }
}
}
["requestFactory":"Http\Client\Common\HttpMethodsClient":private]=> object(Http\Message\MessageFactory\GuzzleMessageFactory)#2889 (0) { }
}
}
Maybe it's just me, but aren't slack webhooks supposed to work with a single channel only? If yes, how come we've got $client->to('#accounting')
?
https://packagist.org/packages/nexylan/slack
Some information are out of date, like the Laravel support.
declare(strict_types=1);
use Nexy\Slack\Attachment;
use Nexy\Slack\Client;
Must be fixed with php-cs-fixer.
Some changes was never released: 1.7.0...master
Try to write a complete changelog and push it for a 2.0 release to be sure to avoid any BC break.
How can I use the select channel feature when I have to select only 1 channel when creating a webhook?
Message
's constructor requires a Client
instance. Since there is now a ClientInterface
, could the typehint for this argument be updated to use it?
Requirements state PHP 7.3+
, but currently only 7.3 or 7.4 is supported.
Move array constructors to real parameters (or option resolver) for following classes:
ActionConfirmation
Attachment
AttachmentAction
AttachmentField
Update the doc accordingly.
After #4
How could i test this bundle?
I can make a PR myself, would you like to merge it?
Need to get sent message's ID, so I can later start a thread using that ID. That's kind of essential. Wouldn't break back compatibility. That's it to say, I have a better way - not gonna expose raw ResponseInterface outside
Hi,
Are "Link Action Buttons" supported? I can't see how to set the URL for them.
https://api.slack.com/docs/message-attachments#link_buttons
Thanks for the great library ๐
HI, im following a tutorial of symfony and i have to use this bundle. I follow all the installation but when i refresh my page appears this error:
Argument 1 passed to Nexy\Slack\Client::__construct() must implement interface Nexy\Slack\ClientInterface, instance of Http\Client\Common\HttpMethodsClient given
I don't find any kind of solution for it, so if someone can help me. Thanks
As minimum requirement. BC break are allowed as we will release a new major soon.
As classe are now final, the properties should not be protected.
php-http/client-implementation package removed.
Please change alternatives.
Command output:
Problem 1
- Installation request for nexylan/slack ^2.0 -> satisfiable by nexylan/slack[v2.0.0].
- nexylan/slack v2.0.0 requires php-http/client-implementation ^1.0 -> no matching package found.
See maknz/slack#67
If possible: https://www.php-fig.org/psr/psr-18/
See also: http://docs.php-http.org/en/latest/discovery.html?highlight=psr#psr-17-factory-discovery (and below)
New requirement notation, package sort, suggest message simplification...
Require sllh/composer-lint
on Travis.
I have trouble sending a message on SF4.
Could you please give me an advice?
SlackController.php
$form = $this->createForm(FormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$slack = $this->get('nexy_slack.client');
$message = $slack->createMessage();
$message
->from($data['from'])
->to('#general')
->withIcon(':ghost:')
->setText($data['message'])
;
return $client->$slack->sendMessage($message);
}
return $this->render('app/contact/slack.html.twig', array(
"locale" => $locale,
"form" => $form->createView(),
));
ErrorException
Catchable Fatal Error: Object of class Nexy\Slack\Client could not be converted to string
And update the documentation for message accordingly.
After the discussion in maknz/slack#95 with @maknz, he would like an approbation of all the contributors to confirm the LICENSE change made on v2.0 of this library.
I already did the change because to me, making a new major is enough, as it was done for swift-mailer. It seems not for many people and I'm OK with that.
However, I need an explicit "YES" from each person who has contributed code. Is everyone okay with this?
Of course, if somebody does not want the change, the LICENSE would go back to the v1 one.
To simplify options management.
We may consider removing the setters if they can't be used by the resolver.
^3.4
version to have array validation (symfony/symfony#15524).
Client::createMessage
. Find a way to pass them directly to the resolver.
Using command:
composer require nexylan/slack php-http/guzzle6-adapter
Gets this:
Problem 1
- Conclusion: don't install nexylan/slack 2.x-dev
- Installation request for php-http/guzzle6-adapter ^2.0@dev -> satisfiable by php-http/guzzle6-adapter[2.x-dev, v2.0.0].
- Installation request for nexylan/slack ^2.0@dev -> satisfiable by nexylan/slack[2.x-dev, v2.0.0].
- nexylan/slack v2.0.0 requires php-http/client-common ^1.7 -> satisfiable by php-http/client-common[1.7.0, 1.8.0, 1.8.1, 1.8.x-dev].
- php-http/client-common 1.7.0 requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
- php-http/client-common 1.8.0 requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
- php-http/client-common 1.8.1 requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
- php-http/client-common 1.8.x-dev requires php-http/httplug ^1.1 -> satisfiable by php-http/httplug[v1.1.0].
- Conclusion: don't install php-http/httplug v1.1.0
Some properties are underscore cased and must be updated.
When symfony/symfony#25763 will be merged and released.
Can be a patch as it should be always an array of strings.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.