Gupshup 无法发送创建 webview 的请求
Gupshup can't send request to create webview
我正在尝试为我的 python facebook bot 创建 webview,但总是收到 404 错误响应。代码(没有令牌和 callback-url):
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)
当我试图从 headers 中删除 api 令牌时,它给了我“401 未经授权。请传递 API 密钥”
文档:https://www.gupshup.io/developer/docs/bot-platform/guide/serverless-webviews-using-gupshup
将您的 headers 更改为以下其中一项,它应该会开始工作
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
'apikey': 'Your_apikey'
}
或
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'apikey': 'Your_apikey'
}
我正在尝试为我的 python facebook bot 创建 webview,但总是收到 404 错误响应。代码(没有令牌和 callback-url):
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)
当我试图从 headers 中删除 api 令牌时,它给了我“401 未经授权。请传递 API 密钥”
文档:https://www.gupshup.io/developer/docs/bot-platform/guide/serverless-webviews-using-gupshup
将您的 headers 更改为以下其中一项,它应该会开始工作
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
'apikey': 'Your_apikey'
}
或
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'apikey': 'Your_apikey'
}