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