我正在使用ROBLOX的http postasync方法来更新我网站上的数据。当php脚本运行并且显示所需的材料时,我试图发送webhook与discord ...但是,除非我手动加载页面,否则php文件的脚本部分不会运行。
<?php
$token = $_POST["token"];
$type = $_POST["type"];
$pid = $_POST["pid"];
$sid = $_POST["sid"];
$gid = $_POST["gid"];
$name = $_POST["name"];
$players = $_POST["players"];
$max = $_POST["max"];
$cdesc = $_POST["cdesc"];
$sus = $_POST["sus"];
?>
<script type="text/javascript">
function sendLog(){
var hookurl = "***"
tosend = [
'**Server added;**',
'Game Name: <?php echo(json_encode($name)); ?>',
'Game ID: <?php echo(json_encode($gid)); ?>',
'Server ID: <?php echo(json_encode($sid)); ?>',
],
msgJson = {
"attachments": [
{
"color": "#CC09EF",
"text": tosend.join('\n'),
"footer": "Infius Game Logs",
"footer_icon": "http://deersystems.net/assets/images/nfius.png",
}
]
}
post(hookurl, msgJson);
}
function post(url, jsonmsg){
xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/json");
var data = JSON.stringify(jsonmsg);
xhr.send(data);
xhr.onreadystatechange = function() {
if(this.status != 200){
alert("ttt");
}
}
}
</script>
<?php
if($type == 'add' and $sid !=NULL and $gid !=NULL and $name!=NULL and $players !=NULL){
echo "
<script type="text/javascript">
sendLog();
</script>
";
}
?>