<?php
$pddiktiUrl = 'http://localhost:8100/ws/live2.php';
$pddiktiUsername = '063065';
$pddiktiPassword = 'Itka2024*()';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $pddiktiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['act' => 'GetToken', 'username' => $pddiktiUsername, 'password' => $pddiktiPassword]));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
$token = json_decode($response, true)['data']['token'];

echo "Token: $token\n";

$keyword = 'mataram';
$postData = [
    'act' => 'GetPerguruanTinggi',
    'token' => $token,
    'filter' => "nama_perguruan_tinggi ILIKE '%" . $keyword . "%'",
    'limit' => 20
];

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
$responsePT = curl_exec($ch);
echo "Result ILIKE:\n";
echo $responsePT . "\n";

$postData2 = [
    'act' => 'GetPerguruanTinggi',
    'token' => $token,
    'filter' => "lower(nama_perguruan_tinggi) LIKE '%" . strtolower($keyword) . "%'",
    'limit' => 20
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData2));
$responsePT2 = curl_exec($ch);
echo "Result lower(name) LIKE:\n";
echo $responsePT2 . "\n";

curl_close($ch);
