-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathnavtoken.php
More file actions
26 lines (21 loc) · 736 Bytes
/
navtoken.php
File metadata and controls
26 lines (21 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
function get_navtoken() {
$memcache = new Memcache;
$key = 'navtoken';
$navtoken = $memcache->get($key);
if ($navtoken == null) {
$url = 'http://backend.navionics.io/tile/get_key/Navionics_internalpurpose_00001/webapp.navionics.com';
$referer = 'https://webapp.navionics.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_REFERER, $referer);
$navtoken = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if ($info["http_code"] == 200) {
$memcache->set($key, $navtoken, 0, 3600);
}
}
return $navtoken;
}