I have a strange behaviour of file_get_contents. We are behind a proxy, so I needed to set the context of file_get_contents. The strange thing is, on my PC it works fine, but on other PC or at other location it won't work, running into the max_execution_time timeout.
if ($requestType == 'GET') {
$context = [
'http' => [
'method' => 'GET',
'header' => "Authorization: " . dbQueryHelper::getApiKey () . "
" . "Content-Type: application/x-www-form-urlencoded
",
'proxy' => getenv ( 'PROXY' ),
'request_fulluri' => true
],
'ssl' => array(
'SNI_enabled' => false, // Disable SNI for https over http proxies
'proxy' => getenv('PROXY'),
'request_fulluri' => true,
"verify_peer"=>false,
"verify_peer_name"=>false,
)
];
}
$context = stream_context_create ( $context );
$dataraw = [
'email' => getenv('DEVMAIL'),
'userEmail' => $user->getNickname(),
'production' => getenv('PROD')
];
$data = http_build_query ( $dataraw );
$context = dbQueryHelper::getContext ( 'GET' ); // this gets the context from above
$result = file_get_contents ( getenv('RESTAPIURL') . '/getPernrByEmail?' . $data, false, $context );
$result = json_decode ( $result, true );
I also get no error message on the other PCs, only
Warning: file_get_contents(...): in C:\trainingplan\lib\common.php on line 79
I think the strange thing is that the warning contains no error... We don't think it could be the proxy because I use the same proxy everywhere and can also use different proxies - same behaviour, on my PC it works, on others not. I also tried with disabling Firewall and UAC and other security services on other PCs, doesn't work as well... We have no clue what could be the root cause.
Do you have any idea for me?