judul (string): Judul dari posting.
markdown (string): Isi dari posting.
custom (string, opsional): Path kustom untuk URL posting. Jika tidak disediakan, URL akan di-generate secara otomatis.
function generateCustomValue($length = 7) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
return $randomString;
}
$custom = isset($_POST['custom']) && !empty($_POST['custom']) ? $_POST['custom'] : generateCustomValue();
$data = array(
'custom' => $custom,
'markdown' => 'https://klikdisini.com/dapatkan-event'
);
$options = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_HTTPHEADER => array(
"authority: ">gotry.my.id",
"origin: ">https://gotry.my.id",
"referer: ">https://gotry.my.id/developer/"
),
);
$curl = curl_init();
curl_setopt_array($curl, $options);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"status": "success",
"message": "Posting berhasil dibuat",
}
{"status":"success","fungsi":"create_gotry","message":"Gotry berhasil dibuat","color":"green","hasil":{"url":"https:\/\/gotry.my.id\/W4hl4Zo"}}