Update HidiveBridge.php

Changed request from file_get_contents to getContent
This commit is contained in:
peppy6582 2025-01-11 13:19:31 -06:00 committed by GitHub
parent 183909aa4d
commit 7aca073859
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,7 @@
class HidiveBridge extends BridgeAbstract { class HidiveBridge extends BridgeAbstract {
const NAME = 'HIDIVE News Bridge'; const NAME = 'HIDIVE News Bridge';
const URI = 'https://news.hidive.com/'; const URI = 'https://news.hidive.com/';
const DESCRIPTION = 'Returns the latest news from HIDIVE'; const DESCRIPTION = 'Fetches the latest news from HIDIVE.';
const MAINTAINER = 'Your Name'; const MAINTAINER = 'Your Name';
const CACHE_TIMEOUT = 3600; // 1 hour cache const CACHE_TIMEOUT = 3600; // 1 hour cache
@ -26,7 +26,7 @@ class HidiveBridge extends BridgeAbstract {
'Referer: https://news.hidive.com/' 'Referer: https://news.hidive.com/'
]; ];
// Create a stream context // Prepare the HTTP options for getContents
$options = [ $options = [
'http' => [ 'http' => [
'method' => 'POST', 'method' => 'POST',
@ -36,16 +36,14 @@ class HidiveBridge extends BridgeAbstract {
] ]
]; ];
$context = stream_context_create($options); // Use getContents for the HTTP request
$response = getContents($apiUrl, $options);
// Execute the request
$response = file_get_contents($apiUrl, false, $context);
if ($response === false) { if ($response === false) {
returnServerError('Unable to fetch data from HIDIVE API.'); returnServerError('Unable to fetch data from HIDIVE API.');
} }
// Decode the response // Decode the JSON response
$data = json_decode($response, true); $data = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE) { if (json_last_error() !== JSON_ERROR_NONE) {
returnServerError('Failed to decode JSON: ' . json_last_error_msg()); returnServerError('Failed to decode JSON: ' . json_last_error_msg());