jasqia@jasqia0121mac ~ %
curl -i -k -H "Content-type: application/json" -X POST -d '{
"blocks":[
{
"type":"section",
"text":{
"type":"mrkdwn",
"text":"*Welcome to the imagination world*"
}
},
{
"type":"section",
"block_id":"section567",
"text":{
"type":"mrkdwn",
"text":"http://www.google.com "
},
"accessory":{
"type":"image",
"image_url":"https://files.slack.com/files-pri/T28JEQ9RV-F024A8BTXE3/icon.jpeg",
"alt_text":"Say Hi"
}
}
]
}' https://hooks.slack.com/services/T28JEQ9RV/B024MUM8URK/ccc

and if you use Python language, it is quit easy
import json
import requests
def alert2Slack(webhook, message):
headers = {
"Content-Type": "application/json",
"charset": "utf-8"
}
url = webhook
value = message
response = requests.request("POST", url, data=json.dumps(value, ensure_ascii=False).encode('utf-8'),
headers=headers)
return response
if __name__ == "__main__":
webhook = "https://hooks.slack.com/services/xxxx"
message = {
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Welcome to the imagination world*"
}
},
{
"type": "section",
"block_id": "section567",
"text": {
"type": "mrkdwn",
"text": "
*The event Time is:* " + "
*The issue website is:* xxx" +
"
@jasmine.qian" + "
*The log information is as the following:* http://www.google.com "
},
"accessory": {
"type": "image",
"image_url": "https://files.slack.com/files-pri/T28JEQ9RV-F024A8BTXE3/icon.jpeg",
"alt_text": "Say Hi"
}
}
]
}
alert2Slack(webhook, message)
------------------------- A little Progress a day makes you a big success... ----------------------------