简单 PHP discord 通知现在以错误代码 50006 响应
Simple PHP discord notification now respond with error code 50006
我有一个简单的日常 PHP 通知到 discord webhook。它已经工作了将近一年,但它现在回复我一个错误:
{"message": "Cannot send an empty message", "code": 50006}
$content
是之前创建并填充的,不是空的。
我在这里替换了真实的用户名和头像link
$hookObject = json_encode([
"type" => "rich",
"content" => "**Rotation today**\n\n".$content,
"username" => "avatar",
"avatar_url" => "link to avatar",
"tts" => false,
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
$ch = curl_init();
curl_setopt_array( $ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $hookObject,
CURLOPT_HTTPHEADER => [
"Length" => strlen( $hookObject ),
"Content-Type" => "application/json"
]
]);
$response = curl_exec( $ch );
curl_close( $ch );
有谁知道现在可能是什么问题?
我昨天也遇到了这个错误。
我找到了这段代码并且它有效:
//===========================================
// Create new webhook in your Discord channel settings and copy&paste URL
//===========================================
$webhookurl = "YOUR_WEBHOOK_URL";
//===========================================
// Compose message. You can use Markdown
// Message Formatting -- https://discordapp.com/developers/docs/reference#message- formatting
//===========================================
$msg = "Test **message** ";
$json_data = array ('content'=>"$msg");
$make_json = json_encode($json_data);
$ch = curl_init( $webhookurl );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
我有一个简单的日常 PHP 通知到 discord webhook。它已经工作了将近一年,但它现在回复我一个错误:
{"message": "Cannot send an empty message", "code": 50006}
$content
是之前创建并填充的,不是空的。
我在这里替换了真实的用户名和头像link
$hookObject = json_encode([
"type" => "rich",
"content" => "**Rotation today**\n\n".$content,
"username" => "avatar",
"avatar_url" => "link to avatar",
"tts" => false,
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
$ch = curl_init();
curl_setopt_array( $ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $hookObject,
CURLOPT_HTTPHEADER => [
"Length" => strlen( $hookObject ),
"Content-Type" => "application/json"
]
]);
$response = curl_exec( $ch );
curl_close( $ch );
有谁知道现在可能是什么问题?
我昨天也遇到了这个错误。 我找到了这段代码并且它有效:
//===========================================
// Create new webhook in your Discord channel settings and copy&paste URL
//===========================================
$webhookurl = "YOUR_WEBHOOK_URL";
//===========================================
// Compose message. You can use Markdown
// Message Formatting -- https://discordapp.com/developers/docs/reference#message- formatting
//===========================================
$msg = "Test **message** ";
$json_data = array ('content'=>"$msg");
$make_json = json_encode($json_data);
$ch = curl_init( $webhookurl );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );