Skip to content

Commit

Permalink
Update KBBIModel.php
Browse files Browse the repository at this point in the history
  • Loading branch information
dyazincahya authored Nov 5, 2024
1 parent 5e2729a commit 7e3e9c9
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions KBBIModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ private function _fetchHtml($word)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Disable SSL host verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL peer verification
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_USERAGENT, 'Localhost');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Forwarded-For: 127.0.0.1']);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);

$response = curl_exec($ch);

Expand All @@ -43,7 +48,12 @@ private function _request__KBBI_API_Zhirrr($word)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Disable SSL host verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL peer verification
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_USERAGENT, 'Localhost');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Forwarded-For: 127.0.0.1']);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);

$response = curl_exec($ch);

Expand Down Expand Up @@ -319,15 +329,14 @@ public function searchWord($word)
return $_KBBI_official;
}
} catch (\Exception $e) {
// ZHIRRR
$_KBBI_byZhirrr = $this->_KBBI_byZhirrr($word);
if(count($_KBBI_byZhirrr))
{
return $_KBBI_byZhirrr;
}
// Log the error message or handle it as needed
error_log("Official API error: " . $e->getMessage());
}

// ZHIRRR
$_KBBI_byZhirrr = $this->_KBBI_byZhirrr($word);
if(count($_KBBI_byZhirrr))
{
return $_KBBI_byZhirrr;
// error_log("Official API error: " . $e->getMessage());
}

return false;
Expand Down

0 comments on commit 7e3e9c9

Please sign in to comment.