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