Send Hyperlink to call an api in Slack message

怎甘沉沦 提交于 2019-12-12 18:04:55

问题


my question is very simple. I want to send a link/button with a slack message and when receiver click on that link it calls an api to perform some task. here is my code:

$msg = "hey! click to approve <a href='http://api2342.in/API/api.php'>Approve</a>";
self::sendSlackMessage($slackId,$msg);

I have this sendSlackMessage API to send a message to the Slack user which receives two parameters, and its working fine. I just need to figure out how to send a link to call an API to perform a certain task.


回答1:


This is very easy to do, just use the correct syntax for links in messages, which is <http://www.foo.com|www.foo.com>.

So for your example:

$msg = "hey! click to approve <http://api2342.in/API/api.php|Approve>";

Check out the excellent official documentation for more information on how to use links with Slack.

Or if you want to improve your user experience use link buttons instead of a naked link.



来源:https://stackoverflow.com/questions/49611493/send-hyperlink-to-call-an-api-in-slack-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!