An open API service indexing awesome lists of open source software.

https://github.com/diewland/line-richmenu-api

create LINE rich-menu from API
https://github.com/diewland/line-richmenu-api

api line python richmenu

Last synced: 3 months ago
JSON representation

create LINE rich-menu from API

Awesome Lists containing this project

README

        

# LINE Richmenu API
create LINE rich-menu from API

### Example
```python
import os
from pprint import pprint as pp

# init api
access_token = os.environ.get('LINE_ACCESS_TOKEN')
api = LINERichmenuAPI(access_token)

# sample user_id, menu config
user_id = '----------'
config = {
"size": {
"width": 2500,
"height": 1686
},
"selected": False,
"name": "Nice richmenu",
"chatBarText": "Tap here",
"areas": [
{
"bounds": {
"x": 0,
"y": 0,
"width": 2500,
"height": 1686
},
"action": {
"type":"message",
"text":"Welcome rich-menu!"
}
}
]
}

# setup menu ( first time only )
api.remove_all_menus(True)
resp = api.create_menu(config, './sample.png')
menu_id = resp['richMenuId']

# link/unlink menu (per user) as much as you want
api.unlink_user_menu(user_id)
api.link_user_menu(user_id, menu_id)

# view script result
pp(api.list_menus())
```
### Reference(s)
https://developers.line.me/en/docs/messaging-api/using-rich-menus/