I’m curious, do you have an example of how you solved the problem with the PHP driver?
AFAIK, there is no way to create attachments over the api, using create post (yet).
You can only use webhooks for that.
The Python driver has a method hooks.call_webhook
You can use this one, to call a webhook you created, and pass the attachment in the options.
For example:
In Mattermost you first have to…
Menu -> Integrations -> Incoming Webhook -> Add Incoming webhook
Note the id, like 1aepn8aosidbzf8in3q49cbt4o.
Set up the python driver and call foo.hooks.call_webhook('1aepn8aosidbzf8in3q49cbt4o', options={"attachments": []}
You can send data from request library of Python
Add everything in a JSON ( Here: Payload )
payload = {
“channel”: “testchannel”,
“username”: “lunch-bot”,
“icon_url”: “https://images.g2crowd.com/uploads/product/image/large_detail/large_detail_1508920769/chatbotsbuilder.png”,
“text”: “# Hello, your lunch is ready\n_Come up if you want fresh food._ ”,
“attachments”: [{
“color”: “#FF8000”,
“pretext”: " this is the attachments pretext ",}]
}
and use post method of request to the incoming webhooks URL you have created.