0
我想为我的python facebook bot创建webview,但始终得到404错误的响应。代码(无令牌和回调网址):Gupshup无法发送请求来创建webview
import requests
from json import loads, dumps
from urllib.parse import quote_plus as urlencode
API_URL = "https://api.gupshup.io/sm/api/"
fields = [{
"type": "input",
"name": "curr_time",
"label": "Enter time"
}, {
"type": "input",
"name": "name",
"label": "Apartment address"
}]
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/plain',
'apikey': 'my_token',
}
data = {
"title": 'Create apartment',
"autoClose": True,
"message": 'Apartment created!',
"callback-url": 'https://mycallback_url',
"fields": fields,
"users": ['My first form']
}
data = dumps(data)
data = 'formJSON=' + urlencode(data)
r = requests.post(API_URL + "facebook/smartmsg/form/create", data=data, headers=headers)
print(r)
print(r.content)
print(r.text)
当我试图从头部取出apitoken它给了我“401未经授权请通过API密钥。”
文档:https://www.gupshup.io/developer/docs/bot-platform/guide/serverless-webviews-using-gupshup
而且网上API:https://www.gupshup.io/developer/ent-apis