I get file_get_contents(https://koinex.in/api/ticker):failed to open stream: HTTP request failed! error
what am I doing wrong?
I get file_get_contents(https://koinex.in/api/ticker):failed to open stream: HTTP request failed! error
what am I doing wrong?
You may try something like this:
$context = stream_context_create([
'http'=> [
'method'=> 'GET',
'user_agent'=> $_SERVER['HTTP_USER_AGENT']
]
]);
$data = json_decode(
file_get_contents('https://koinex.in/api/ticker', false, $context)
);
The following https://koinex.in/api/ticker
works from browser so it seems that all you need to set a user_agent
to fool the server that the request is being made by a real user using a browser. Also read about stream_context_create.