-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.php
97 lines (81 loc) · 3.17 KB
/
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
public function postToDiscord()
{
//You can see how to get the webhookurl here: https://help.dashe.io/en/articles/2521940-how-to-create-a-discord-webhook-url
$webhookurl = "####";
$timestamp = date("c", strtotime("now"));
$json_data = json_encode([
// Message
"content" => "My Truong Test API Webhook ",
// Username
"username" => "mytruong",
// Text-to-speech
"tts" => false,
// File upload
// "file" => "",
// Embeds Array
"embeds" => [
[
// Embed Title
"title" => "My Truong Test API Webhook",
// Embed Type
"type" => "rich",
// Embed Description
"description" => "description",
// URL of title link
"url" => "https://gist.github.com/mytruong-z",
// Timestamp of embed must be formatted as ISO8601
"timestamp" => $timestamp,
// Embed left border color in HEX
"color" => hexdec( "3366ff" ),
// Author
"author" => [
"name" => "BoiGiaTrang",
"url" => "https://boigia.space/"
],
// Additional Fields array
"fields" => [
// Field 1
[
"name" => "Account",
"value" => "Nongdan02",
"inline" => false
],
// Field 2
[
"name" => "Health",
"value" => "1000",
"inline" => false
],
// Field 3
[
"name" => "SLP",
"value" => "1000",
"inline" => false
],
// Field 4
[
"name" => "Level Pet",
"value" => "20",
"inline" => true
],
// Field 5
[
"name" => "Rank",
"value" => "1230",
"inline" => true
]
]
]
]
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
$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, $json_data);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
curl_close( $ch );
return $response;
}