I have a method which sends a message to Facebook in Generic template . My code:
def send_receipt(self, fbid, title, url, img_url, summary):
return self._send(message={
"recipient": {
"id": fbid
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": title,
"item_url": url,
"image_url": img_url,
"subtitle": summary
}
]
}
}
}
})
It works fine for me, but it only returns 1 element. I want to get 2 or 3 elements from JSON, so I think that I can make it work by making an element object, and this object returns the array list.
def send_receipt(self, fbid, elements):
return self._send(message={
"recipient": {
"id": fbid
},
"message": {
"attachment": {
"type": "template",
"payload": {
"template_type": "generic",
"elements": elements
}
}
}
})
And I did make a method to return elements. But I'm new to python, so what I have done didn't work for me.
elements = [{
"title": title,
"item_url": url,
"image_url": img_url,
"subtitle": summary }]