I'm trying to query a website using the php query, but getting error:
$ php main.php
PHP Warning: file_get_contents(https://api.transport.nsw.gov.au/v1/tp/stop_finder?
outputFormat=rapidJSON&type_sf=any&name_sf=Wynyard+Station&
coordOutputFormat=EPSG%3A4326&TfNSWSF=true): failed to open stream: HTTP request failed!
HTTP/1.1 401 Unauthorized
in /home/cg/root/7504993/main.php on line 14.
Is there anything that I'm missing?
Tried - "Integrated Windows Authentication", under Tools > Security > Local Intranet zone > Sites > Advanced, the target web site is listed.
<?php
// User's search query
$apiEndpoint = 'https://api.transport.nsw.gov.au/v1/tp/';
$apiCall = 'stop_finder';
// Build the request parameters
$params = array(
'outputFormat' => 'rapidJSON',
'type_sf' => 'any',
'name_sf' =>'Wynyard Station',
'coordOutputFormat' => 'EPSG:4326',
'TfNSWSF' => 'true'
);
$url = $apiEndpoint . $apiCall . '?' . http_build_query($params);
$response = file_get_contents($url);
$json = json_decode($response, true);