如何解决尝试通过heroku Webapp将数据发布到不和谐Webhook的问题
我正在尝试通过heroku Webapp(Python)将某些数据发布到不和谐的Webhook中。我之所以这样做,是因为它更安全并且不会将webhook分发给任何人。出于某种奇怪的原因,它在调用时不会发布任何内容(该Webapp正在用Lua编写的游戏中调用,对于绝对令人作呕的代码也表示歉意。)
import functions #this is a library that will get the games current player rate and the name. The problem is NOT in this library,i've tested everything and it all works fine.
import requests
import json
url = "https://discord.com/api/webhooks/mywebhook" #the webhook that the data will be sent to
def send(gameid,placeid):
embeddata = {}
embeddata["embeds"] = []
embed = {}
embed["description"] = "Game Status"
embed["title"] = "status ok"
embeddata["embeds"].append(embed)
embed["fields"] = []
embedfields1 = {}
embedfields2 = {}
embedfields1["name"] = "Game Name"
embedfields1["value"] = functions.get_name(gameid)
embedfields2["name"] = "Playing"
embedfields2["value"] = functions.get_playing(gameid)
embed["fields"].append(embedfields1)
embed["fields"].append(embedfields2)
result = requests.post(url,data=json.dumps(embeddata),headers={"Content-Type": "application/json"})
在同一目录中也有一个main.py,它实际上执行上面的代码
from flask import Flask,request,jsonify
import json
import webhook
app = Flask(__name__)
@app.route('/send',methods=["POST"])
def send():
try:
webhook.send(request.args["gameid"],request.args["placeid"])
return jsonify({"Success": "Posted to webhook"})
except:
return jsonify({"Error": "An internal error has occured"})
这是游戏(Lua)的内容:
local HttpService = game:GetService("HttpService") -- gets games http service
-- .. is concatenation
function post()
HttpService:PostAsync("https://MYHEROKUAPPNAME.herokuapp.com/send?gameid=" .. game.GameId .. "&placeid=" .. game.PlaceId)
end
post()
很抱歉,如果这是一个很奇怪的情况,只是想完成这个,这个网站是我最后的希望。谢谢您的时间和精力!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。