Page 1 of 1

UK Tides API.

Posted: Wed Aug 08, 2018 9:45 pm
by Toxic17
I'm trying to get a new wxtidesuk page working but have run into some problem with the code.

the website supplies php code like so:

Code: Select all

<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://admiraltyapi.azure-api.net/uktidalapi/api/V1/Stations/{stationId}');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_GET);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>


the problem is the

require_once 'HTTP/Request2.php';

which I do not have and it doesn't look like I can compile the PEAR module on my NAS. so is there an Alternative way around this?

https://admiraltyapi.portal.azure-api.net/

Re: UK Tides API.

Posted: Wed Aug 08, 2018 9:58 pm
by beteljuice
Well ... here is the PEAR module .. https://pear.php.net/package/HTTP_Request2 and all documentation.

Re: UK Tides API.

Posted: Wed Aug 08, 2018 10:03 pm
by Toxic17
beteljuice wrote:Well ... here is the PEAR module .. https://pear.php.net/package/HTTP_Request2 and all documentation.


Thanks but I cannot install PEAR on the NAS.

cancel my last. just found pear on the NAS and managed to pull the data down.! :groan: