def post_call_button(fbid, text, title, phone_number):
""" Sends a call button for the specified user
(/docs/messenger-platform/send-api-reference/call-button).
:param str fbid: User id to send the call button
:param str text: Text to send with the button (Max 160 Chars).
:param str title: Button title (Max 20 Chars).
:param str phone_number: Format must have "+" prefix followed by\
the country code, area code and local number.\
For example, **+16505551234**.
:return: `Response object <http://docs.python-requests.org/en/\
master/api/#requests.Response>`_
"""
url = MSG_URL + PAGE_ACCESS_TOKEN
data = {}
data['recipient'] = {'id': fbid}
payload = {}
payload['template_type'] = 'button'
payload['text'] = text
button = {}
button['type'] = 'phone_number'
button['title'] = title
button['payload'] = phone_number
payload['buttons'] = [button]
attachment = {"type": "template", "payload": payload}
data['message'] = {"attachment": attachment}
data = json.dumps(data)
status = requests.post(url, headers=HEADER, data=data)
return status
评论列表
文章目录