接收Webhook通知不起作用?

时间:2018-11-28 17:06:47

标签: php api

因此,我尝试向自己购买,以查看网络挂钩是否真的有效。我为什么在这里?因为不是。

这是我的代码;

<?php
function postToDiscord($message, $webhook)
{
    $data = array("content" => $message, "username" => "TEST");
    $curl = curl_init($webhook);
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    return curl_exec($curl);
}

if (!isset($_POST['status'])) {
killmyself();
}

if ($_POST['status'] != 100) {
exit();
}

$json = json_decode($_POST['custom'], true);
$username = $json['0'];
$a = $_POST['usd_value'];
echo 1;
if ($a == "1.0") {
$highfives = "1500";
} elseif ($a == "2.0") {
$highfives = "3000";
} elseif ($a == "5.0") {
$highfives = "7500";
} elseif ($a == "10.0") {
$highfives = "15000";
} elseif ($a == "15.0") {
$highfives = "22500";
} elseif ($a == "20.0") {
$highfives = "30000";
} elseif ($a == "30.0") {
$highfives = "45000";
} elseif ($a == "50.0") {
$highfives = "75000";
} elseif ($a == "100.0") {
$highfives = "150000";
} else {
killmyself();
}
echo "<br>".$highfives."<br>";
echo 2;

$servername = "localhost";
$user = "alexbql297_abcd";
$password = "GONE";
$dbname = "alexbql297_abcd";
$fail = true;
$conn = new mysqli($servername, $user, $password, $dbname);
$sql = "SELECT username, id, amount FROM users";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
if (strtolower($row['username']) == strtolower($username)) {
echo 3;
$oldamount = $row['amount'];
$newamount = $row['amount'] + $highfives;
$id = $row['id'];
$fail = false;
}
}

if ($fail) {
header("HTTP/1.1 201 NOK");

echo 4;
postToDiscord("```\nemail: ".$_POST['email']."\nip: ".$_POST['ip']."\namount: ".$_POST['usd_value']."\n```", "https://discordapp.com/api/webhooks/517369108078002186/cPoX4Dr3CpSGxkbld-dN3cPVrEIJ3uEypn01v_dwyBVfibKmpjl82ud4ZDzGyBn5xkMq");
exit();
} else {
echo 5;
$sql = 'INSERT INTO payments (data) VALUES ('."'".json_encode($_POST)."'".')';
$conn->query($sql);
$sql = "UPDATE users SET amount='".$newamount."' WHERE id=".$id;
$conn->query($sql);
postToDiscord("```username: ".$username."\npayed: ".$_POST['usd_value']."\nold bal: ".$oldamount."\nnew bal: ".$newamount."```","https://discordapp.com/api/webhooks/517369877653094416/4-sSQDWavX9FJjtpfdtyY0RgkdsZtwH9VpaLpkw3kwGpSuTsVneOEf6-eCVqjXJ96921");
}

echo 6;

function killmyself() {
exit('
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>404 Not Found</TITLE>
</HEAD><BODY>
<H1>Not Found</H1>
The requested URL /ok.php was not found on this server.
<HR>
<I>highfiveee.us</I>
</BODY></HTML>




























































































































































































































































');
}
?>

这里是Selly.gg api文档的链接; https://developer.selly.gg/?php#webhooks因此,它实际上应该做的事情(如果我没看错的话)。但事实并非如此。这是“重试” webhook的屏幕截图; click here

希望有人可以帮助我。它不会将其登录到payments或Discord中。

0 个答案:

没有答案